删除选中的玻璃高亮列表视图并将鼠标悬停在项目上

时间:2014-04-23 16:24:25

标签: c# .net wpf xaml listview

我正在个性化listview的风格,

但是有一种玻璃效应,我没有设法删除......

以下是包含空数据的listview图片

ugly style selected item

第一个橙色元素是标题,然后是所选项目,然后是鼠标悬停项目。

我试着把所有东西当作标题平坦和垫子。

任何人都知道该怎么办?我尝试过几件事......

编辑:添加XAML代码

列表视图:

<ListView Style="{DynamicResource ListViewStyle1}" ItemContainerStyle="{DynamicResource ListViewItemStyle1}" x:Name="AffairesList" Margin="0,0,0,0" ItemsSource="{Binding affaires.Affaires}" MouseDoubleClick="AffairesList_MouseDoubleClick" AlternationCount="2"  >            
    <ListView.View>
        <GridView>
            <GridViewColumn Header="ID" DisplayMemberBinding="{Binding Path=ID}" />
            <GridViewColumn Header="Nom" DisplayMemberBinding="{Binding Path=name}" />
        </GridView>
    </ListView.View>
</ListView>

ListViewItemStyle1:

<Style x:Key="ListViewItemStyle1" TargetType="{x:Type ListViewItem}">
    <Setter Property="Background" Value="#FFEBEBEB"/>
    <Setter Property="Foreground" Value="Black"/>
    <Setter Property="Height" Value="40"/>
    <Style.Triggers>
        <MultiTrigger>
            <MultiTrigger.Conditions>
                <Condition Property="IsSelected" Value="true" />
                <Condition Property="Selector.IsSelectionActive" Value="true" />
            </MultiTrigger.Conditions>
            <Setter Property="Background" Value="#FFFFA200" />
        </MultiTrigger>
        <Trigger Property="IsMouseOver" Value="true">
            <Setter Property="Background" Value="#FFFFA200"/>
        </Trigger>
    </Style.Triggers>
</Style>

ListViewStyle1(我想我必须修改主题:ListBoxChrome部分):

<Style x:Key="ListViewStyle1" TargetType="{x:Type ListView}">
    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
    <Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="Foreground" Value="#FF042271"/>
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
    <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
    <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
    <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ListView}">

                <Themes:ListBoxChrome x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderFocused="{TemplateBinding IsKeyboardFocusWithin}" SnapsToDevicePixels="true">
                    <ScrollViewer Padding="{TemplateBinding Padding}" Style="{DynamicResource {x:Static GridView.GridViewScrollViewerStyleKey}}">
                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </ScrollViewer>
                </Themes:ListBoxChrome>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsEnabled" Value="false">
                        <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                    </Trigger>
                    <MultiTrigger>
                        <MultiTrigger.Conditions>
                            <Condition Property="IsGrouping" Value="true"/>
                            <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
                        </MultiTrigger.Conditions>
                        <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                    </MultiTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

0 个答案:

没有答案