O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using a Base TargetType

Although the Style in Figure 18.1 is shared among three Buttons, it can be shared by any kind of Control if you mark it with TargetType="Control" instead:

<Page ...>...        <Style x:Key="PurpleTiltStyle" TargetType="Control" >...      <Button Style="{StaticResource PurpleTiltStyle}" Content="1"/>      <ToggleSwitch Style="{StaticResource PurpleTiltStyle}"/>      <ProgressRing IsActive="True" Style="{StaticResource PurpleTiltStyle}"/>...</Page>

The result is shown in Figure 18.2. Note that ToggleSwitch’s default appearance enforces a minimum width, so it ignores the Style’s Width setting.

FIGURE 18.2 Heterogeneous controls given the same Style

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required