새로운 문제가 나와서, 나는 파란색 테두리
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter
x:Name="contentPresenter"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
없이 목록 상자를 획득하지만이
<Style TargetType="ListBoxItem" x:Key="ContainerStyle">
<Setter Property="ContentTemplate" Value="{StaticResource not_mouseover}"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="ContentTemplate" Value="{StaticResource mouseover}"/>
</Trigger>
</Style.Triggers>
</Style>
<ListBox ItemsSource="{Binding lista}" ItemContainerStyle="{StaticResource ContainerStyle}">
처럼 ItemContainerStyle 설정
이 경우에는 작동하지 않는다는 것을 알 수 있습니다 (이전과 같이 파란색 테두리가 나타남). ItemTemplate을 지정된 DateTemplate으로 설정하면 제대로 작동하지만 여기서는 그렇지 않습니다. 왜 그런지 아십니까? 나는 이것을 분류했다. 그냥 하나 개의 ListBoxItem의
<Style x:Key="item_template" TargetType="ListBoxItem">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Template" Value="{StaticResource control_mouseover}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Template" Value="{StaticResource control_not_mouseover}"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<ListBox ItemsSource="{Binding lista}" ItemContainerStyle="{StaticResource item_template}">
</ListBox>
에 대한 스타일과 아마 누군가가이 활용됩니다 블루 국경
<ControlTemplate x:Key="control_not_mouseover" TargetType="ListBoxItem">
<ContentPresenter
Content="{TemplateBinding Content}"
ContentTemplate="{StaticResource not_mouseover}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"/>
</ControlTemplate>
<ControlTemplate x:Key="control_mouseover" TargetType="ListBoxItem">
<ContentPresenter
Content="{TemplateBinding Content}"
ContentTemplate="{StaticResource mouseover}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"/>
</ControlTemplate>
을 제거하기 위해 ControlTemplate이를 선언했다.
답변을보다 정확하게 작성하십시오. – Maximus
Chris W 응답 완료. – Tico