Styling a selected ListViewItem in Windows 8 CP(在 Windows 8 CP 中为选定的 ListViewItem 设置样式)
问题描述
我想改变下图中所选项目的边框外观.
I want to change the appearance of the Border of the selected Item in the picture linked below.
我已经在 msdn.com 和互联网上四处寻找,但没有发现任何有用的东西.
I've already been looking around on msdn.com and on the internet, but I've found nothing useful.
我该怎么做?
推荐答案
选择外观是 ListViewItem 的 ControlTemplate 的一部分.要修改整个 ListView 的模板,请使用 ItemContainerStyle 将样式应用于每个项目,其中可以包含模板的修改版本.
The selection appearance is part of the ControlTemplate for ListViewItem. To modify the template for an entire ListView use the ItemContainerStyle to apply a Style to each item, which can contain a modified version of the template.
<ListView>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
...
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
ListViewItem 的默认模板非常复杂,因此为了尽可能多地保留默认行为并为您提供一个良好的起点,使用 Blend 为您创建一个副本是最简单的.
The default template for ListViewItem is pretty complex so in order to preserve as much of the default behavior as possible and give you a good starting point, it's easiest to use Blend to create a copy for you.
在 Blend 中,右键单击您的 ListView 并选择:
In Blend, right-click your ListView and select:
编辑其他模板 -> 编辑生成的项目容器 -> 编辑副本...
它会在上面的表格中为您创建一个样式,并填充默认模板.选择外观使用模板中的几个不同元素,您可能想要修改这些元素 - 这些可以通过在中选择 Selected 状态来查看Blend 中的状态"面板并深入到对象"面板中突出显示的项目.
and it will create a Style for you in the form above with the default template filled in. The selection appearance uses a few different elements in the template which you may want to modify - these can be seen by selecting the Selected state in the States panel in Blend and drilling into the highlighted items in the Objects panel.
这篇关于在 Windows 8 CP 中为选定的 ListViewItem 设置样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Windows 8 CP 中为选定的 ListViewItem 设置样式
基础教程推荐
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- WPF 模态进度窗口 2022-01-01
