Mat*_*ton 13
您可以使用ListBox本身中影响其所有项目的样式来执行此操作:
<ListBox.Resources>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver,RelativeSource={RelativeSource Self}}"
Value="True">
<Setter Property="IsSelected" Value="True" />
</DataTrigger>
</Style.Triggers>
</Style>
</ListBox.Resources>
Run Code Online (Sandbox Code Playgroud)
当IsMouseOver属性为true时,这会将项目上的IsSelected属性设置为true.如果您的ListBox不是多选的,它会以您期望的方式工作.
| 归档时间: |
|
| 查看次数: |
10529 次 |
| 最近记录: |