Xaml ListViewItem选择颜色覆盖

Xaml ListViewItem选择颜色覆盖,xaml,windows-runtime,Xaml,Windows Runtime,我需要覆盖ListViewItem的预定义样式,使其不具有可见的选择。如果我将整个样式复制到我的资源中并对其进行编辑,我知道如何做到这一点。但我不敢相信,没有比模仿整个风格更轻松的方法了。 因此,我发现默认ListViewItem样式使用以下笔刷进行选择: <UserControl.Resources> <SolidColorBrush x:Key="ListViewItemPointerOverBackgroundThemeBrush" Color="Yellow"

我需要覆盖ListViewItem的预定义样式,使其不具有可见的选择。如果我将整个样式复制到我的资源中并对其进行编辑,我知道如何做到这一点。但我不敢相信,没有比模仿整个风格更轻松的方法了。 因此,我发现默认ListViewItem样式使用以下笔刷进行选择:

<UserControl.Resources>
    <SolidColorBrush x:Key="ListViewItemPointerOverBackgroundThemeBrush" Color="Yellow" />
    <SolidColorBrush x:Key="ListViewItemSelectedBackgroundThemeBrush" Color="Yellow" />
    <SolidColorBrush x:Key="ListViewItemSelectedForegroundThemeBrush" Color="Yellow" />
    <SolidColorBrush x:Key="ListViewItemSelectedPointerOverBackgroundThemeBrush" Color="Yellow" />
    <SolidColorBrush x:Key="ListViewItemSelectedPointerOverBorderThemeBrush" Color="Yellow" />
</UserControl.Resources>

注意:我已将所有这些画笔置于我的用户控件,并将它们全部设置为黄色。但是我的UI中没有任何黄色,唉。 所以问题是:如何强制默认模板使用覆盖的笔刷?
第二个(可选)问题:也许我做错了,有更好的方法来实现我的目标吗?

我以前也尝试过类似的事情,但运气不佳。我认为您只需要更新整个模板。

您必须在App.xaml文件中覆盖它们,类似这样的内容(至少我是这样做的):



如果您需要更多的自定义(在我的例子中,ListView项目是一些图片),这里有一个非常有用的更改默认值的链接。

正如Vasile所说,您需要覆盖笔刷,这必须在应用程序级别上完成,据我所知,如果您只想更改一个控件或一个页面,您将需要对整个控件进行模板化

如果您好奇,您可以在下面找到所有画笔: C:\ProgramFiles(x86)\Windows工具包\8.0\Include\WinRT\Xaml\Design

为了覆盖您在App.xaml/resource字典中添加的listview颜色,我在这里添加了一些注释,以便您可以看到哪个笔刷执行以下操作:

            <ResourceDictionary x:Key="Default">

             <!--After selection - Background-->
            <SolidColorBrush x:Key="ListViewItemSelectedBackgroundThemeBrush" Color="Yellow"></SolidColorBrush>

             <!--When pointer hovers over an item - Background-->
            <SolidColorBrush x:Key="ListViewItemPointerOverBackgroundThemeBrush" Color="Red"></SolidColorBrush>

             <!--When the item is selected (first few milliseconds) - Background-->
            <SolidColorBrush x:Key="ListViewItemSelectedPointerOverBackgroundThemeBrush" Color="Green"></SolidColorBrush>

             <!--When the item is selected (first few milliseconds) - Border-->
            <SolidColorBrush x:Key="ListViewItemSelectedPointerOverBorderThemeBrush" Color="Black"></SolidColorBrush>

        </ResourceDictionary>


在共享App.xaml中的Windows 8.1通用App中,我使用此代码

<Application
    x:Class="XXX.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:XXX">

    <Application.Resources>
        <ResourceDictionary>
            <SolidColorBrush x:Key="ListViewItemPointerOverBackgroundThemeBrush" Color="Transparent" />
        </ResourceDictionary>
    </Application.Resources>
</Application>


谢谢,但应用程序范围的笔刷设置对我来说确实不是一个选项。但是,如果没有其他选项,我会接受它作为答案。我只是在设置页面上遇到了这个问题,我在MSDN上发现了一个线程,Tim Heuer在其中回答说,仅页面覆盖画笔是不可能的,仅限于app.xaml。该线程上次更新是在11月。我忍不住想一定有办法。。
<Application
    x:Class="XXX.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:XXX">

    <Application.Resources>
        <ResourceDictionary>
            <SolidColorBrush x:Key="ListViewItemPointerOverBackgroundThemeBrush" Color="Transparent" />
        </ResourceDictionary>
    </Application.Resources>
</Application>