|
<Style x:Key="RadioButtonHorizontalListBox"
TargetType="ListBox">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBox}">
<Border BorderThickness="1,0,0,0"
BorderBrush="{TemplateBinding BorderBrush}">
<ItemsPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="ListBoxItem">
<Setter Property="BorderBrush"
Value="{Binding BorderBrush, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox, AncestorLevel=1}}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<!-- RadioButton -->
<DockPanel Background="{TemplateBinding Background}">
<RadioButton IsChecked="{TemplateBinding IsSelected}"
Focusable="False"
IsHitTestVisible="False"
VerticalAlignment="Center"
Margin="0,0,4,0" />
<ContentPresenter Content="{TemplateBinding ContentControl.Content}"
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
</DockPanel>
<!-- ToggleButton -->
<Grid Background="{TemplateBinding Background}">
<ToggleButton IsChecked="{TemplateBinding IsSelected}"
Content="{TemplateBinding Content}"
Padding="10,5"
BorderThickness="0,1,1,1"
BorderBrush="{TemplateBinding BorderBrush}"
Focusable="False"
IsHitTestVisible="False" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Style>
|