C# GridViewRowPresenter鼠标悬停触发器样式替代

C# GridViewRowPresenter鼠标悬停触发器样式替代,c#,xaml,C#,Xaml,我目前正在开发一个在ListView控件中使用GridView的应用程序 我正在尝试更改选定行上的蓝色悬停/单击效果,但迄今为止,无论我尝试了什么(我尝试了很多东西),我都无法做到这一点 app.xaml中的相关xaml: <Style x:Key="{x:Type ListView}" TargetType="ListView"> <Setter Property="BorderThickness" Value="0" /> </Style> &l

我目前正在开发一个在ListView控件中使用GridView的应用程序

我正在尝试更改选定行上的蓝色悬停/单击效果,但迄今为止,无论我尝试了什么(我尝试了很多东西),我都无法做到这一点

app.xaml中的相关xaml:

<Style x:Key="{x:Type ListView}" TargetType="ListView">
    <Setter Property="BorderThickness" Value="0" />
</Style>

<Style TargetType="{x:Type GridViewRowPresenter}">
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Height" Value="20" /> <!-- This actually works here, but I can't change background -->
        </Trigger>
    </Style.Triggers>
</Style>

Xaml listview代码:

<ListView HorizontalAlignment="Left" Height="668" VerticalAlignment="Top" Width="700" Foreground="#BDBDBD" Background="#090909" Name="Results">
    <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
        </Style>
    </ListView.ItemContainerStyle>
    <ListView.View>
        <GridView AllowsColumnReorder="False">
            <GridViewColumn Header="ID" DisplayMemberBinding="{Binding ID}" Width="130"/>
            <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" Width="220"/>
            <GridViewColumn Header="Details" DisplayMemberBinding="{Binding Details}" Width="120"/>
        </GridView>
    </ListView.View>
</ListView>


我很想学习如何在gridview的模板中更改悬停颜色。。我到处都找过了,但运气不好。。另外,我在windows 7上,但在windows 8上也是一样。

不清楚为什么第一种方法不起作用(必须是,您设置了哪个属性?),但无论如何,这里有一个有效的方法

<ListView ...>
    <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
            <Style.Triggers>
                <Trigger Property="IsMouseOver"
                         Value="True">
                    <Setter Property="Background"
                            Value="Red" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </ListView.ItemContainerStyle>
</ListView>

不清楚为什么您的第一种方法不起作用(它必须起作用,您设置了哪个属性?),但无论如何,这里是一个有效的方法

<ListView ...>
    <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
            <Style.Triggers>
                <Trigger Property="IsMouseOver"
                         Value="True">
                    <Setter Property="Background"
                            Value="Red" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </ListView.ItemContainerStyle>
</ListView>

这种方法奏效了。由于某种原因,高光颜色仍然有一个渐变。这种方法很有效。由于某些原因,高光颜色仍然具有渐变。