【发布时间】:2013-05-04 20:38:43
【问题描述】:
在ListView 中有ListviewItems,当鼠标悬停在它们上方或它们被选中时,它们不得改变外观。
我试图用这种风格来实现这一点,并且有点成功了:
<Style x:Key="ItemContainerStyle1" TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Focusable" Value="False" />
</Trigger>
</Style.Triggers>
</Style>
但它提出了一个新问题。当背景设置为“透明”时,当鼠标悬停在列表视图项上时,我现在可以看到如下图所示的悬停/光泽效果。
我曾尝试通过此尝试解决问题,但没有成功。
<Style TargetType="{x:Type ListViewItem}">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#00000000"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#00000000"/>
</Style.Resources>
</Style>
有人知道如何消除这种悬停效果吗?
【问题讨论】:
-
如果有人只需要控件列表(没有表格),请使用
ItemsControlstackoverflow.com/a/17853517/6131611
标签: .net wpf xaml styles itemcontainerstyle