求助 WPF ListViewItem样式问题
Вопрос
-
<Style TargetType="ListViewItem"> <!--<Setter Property="Margin" Value="0,1,0,0"/>--> <Setter Property="Height" Value="21"/> <Setter Property="Foreground" Value="Black" /> <Setter Property="Background" Value="White" /> <Style.Triggers> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsSelected" Value="true" /> <Condition Property="Selector.IsSelectionActive" Value="true" /> </MultiTrigger.Conditions> <Setter Property="Background"> <Setter.Value> <SolidColorBrush Color="Red" /> </Setter.Value> </Setter> <Setter Property="BorderBrush" Value="{x:Null}" /> </MultiTrigger> <Trigger Property="IsMouseOver" Value="true"> <Setter Property="Panel.Background" > <Setter.Value> <SolidColorBrush Color="#FFE6E6E7" /> </Setter.Value> </Setter> <Setter Property="BorderBrush" Value="{x:Null}" /> <Setter Property="Cursor" Value="Hand"/> </Trigger> </Style.Triggers> </Style> <ListView HorizontalAlignment="Stretch" Margin="0" Name="listView1" VerticalAlignment="Stretch" BorderBrush="{x:Null}" SelectionMode="Single" SelectionChanged="listView1_SelectionChanged" > <ListView.View> <GridView ColumnHeaderContainerStyle="{ StaticResource GridHeaderRight}" > <GridViewColumn Width="100" Header="日期"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Date}" HorizontalAlignment="Left" ></TextBlock> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView>
上面 是我设置的 ListViewItem的代码
结果的效果 鼠标移上去和和选中的背景色应该是 SolidColorBrush 但结果却是渐变色 郁闷啊
Swat- Перемещено Sheng Jiang 蒋晟MVP, Moderator 11 октября 2011 г. 22:05 (发件人:.NET Framework 一般性问题讨论区)
Все ответы
-
我给ListViewItem设置样式的时候 的时候 出现了 一个问题 请大家帮助下
代码
<Style TargetType="ListViewItem"> <!--<Setter Property="Margin" Value="0,1,0,0"/>--> <Setter Property="Height" Value="21"/> <Setter Property="Foreground" Value="Black" /> <Setter Property="Background" Value="White" /> <Style.Triggers> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsSelected" Value="true" /> <Condition Property="Selector.IsSelectionActive" Value="true" /> </MultiTrigger.Conditions> <Setter Property="Background"> <Setter.Value> <SolidColorBrush Color="Red" /> </Setter.Value> </Setter> <Setter Property="BorderBrush" Value="{x:Null}" /> </MultiTrigger> <Trigger Property="IsMouseOver" Value="true"> <Setter Property="Panel.Background" > <Setter.Value> <SolidColorBrush Color="#FFE6E6E7" /> </Setter.Value> </Setter> <Setter Property="BorderBrush" Value="{x:Null}" /> <Setter Property="Cursor" Value="Hand"/> </Trigger> </Style.Triggers> </Style>
<ListView HorizontalAlignment="Stretch" Margin="0" Name="listView1" VerticalAlignment="Stretch" BorderBrush="{x:Null}" SelectionMode="Single" SelectionChanged="listView1_SelectionChanged" > <ListView.View> <GridView ColumnHeaderContainerStyle="{ StaticResource GridHeaderRight}" > <GridViewColumn Width="100" Header="日期"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Date}" HorizontalAlignment="Left" ></TextBlock> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView>
选择行的背景色 和鼠标移上去 应该是单色 但是却是 渐变 很郁闷啊 求助 谢谢- Изменено 剑仙红世 11 октября 2011 г. 14:07
- Объединено Sheng Jiang 蒋晟MVP, Moderator 11 октября 2011 г. 22:05
-
-
-
你好,
你贴出的代码应该没有什么问题。 实际看到的效果是和ListViewItem的ControlTemplate直接相关的,你可以贴出来看一下吗?
另外,如果你的项目中应用很多样式的话,我建议你新建一个项目,把样式逐个加入,这样可以找到到底是哪个样式出了问题。