DataTemplate이 아닌 내부 항목 컨테이너 스타일을 사용하십시오. 나는. 자신의 ListBoxItem
스타일을 정의하고 필요한 부분 만 강조 표시하십시오. 예컨대 : 다음
<Style x:Key="MyStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid>
<Border
Name="Border"
Margin="0, 0, 0, 1"
Padding="2"
SnapsToDevicePixels="true">
<ContentPresenter />
</Border>
<Border Grid.Row="1" BorderThickness="0, 0, 0, 1" BorderBrush="Black"
SnapsToDevicePixels="True"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="Border" Property="Background" Value="#DDDDDD"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="#888888"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
그리고 :
<ListBox ItemContainerStyle="{StaticResource MyStyle}">
을