在Windows 8 CP造型所选的ListViewItem [英] Styling a selected ListViewItem in Windows 8 CP

查看:117
本文介绍了在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.

我怎样才能做到这一点?

How can I do this?

推荐答案

选择出场的是对的ControlTemplate的ListViewItem的一部分。修改的模板用于整个的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的默认的模板是相当复杂,所以为了尽可能多地保留的默认行为尽可能,并给你一个很好的起点,这是最容易使用混合为您创建一个副本

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:

修改其他模板 - >编辑生成的项容器 - >编辑副本...

它会在上面填写默认模板的形式创建一个样式为您的选择外观使用中,你可能要修改的模板的几个不同的元素 - 这些都可以通过在美国的面板中选择被选中状态可以看出在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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆