I have several styles like this one (left, right, center) that differ only in the which corners (if any) are rounded.
<Style x:Key="ToggleRadioButtonLeft"
TargetType="{x:Type ToggleButton}"
BasedOn="{StaticResource {x:Type ToggleButton}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Border BorderBrush="Blue"
Background="{TemplateBinding Background}"
Padding="15,0"
BorderThickness="1"
CornerRadius="10,0,0,10"> <!-- extract this -->
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="Blue"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
I'd like to be able to create a single base style without rounded any corners (ie the center button style) and then two more based on it that set the rounded corners for the left and rightmost elements, but I can't figure out how to set the border radius in a derived style because it's not the top level element in the style.
Question&Answers:os