【问题标题】:change color in ListView在 ListView 中更改颜色
【发布时间】:2017-02-04 15:19:52
【问题描述】:

Listview 项目为selected 时,我正在尝试更改边框背景。

<Border x:Name="myback" Background="Transparent">
     <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
</Border>

【问题讨论】:

    标签: c# windows-store-apps windows-8.1


    【解决方案1】:

    根据您的代码,我想知道Border是否在ListViewItem的模板内,如果是,请转到以下路径:C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration \Neutral\UAP\10.0.14393.0\Generic\generic.xaml 以获取所有 UWP 控件的所有默认样式。 然后请搜索 ListViewItem 样式,您会找到两个 ListViewItem 样式,请将名为 ListViewItemExpanded 的样式复制到您的项目中,并将您的边框添加到 ListViewItemExpanded 旁边风格。

    之后,为了在选择 ListViewItem 时更改边框背景,请搜索 Selected/PointerOverSelected/PressedSelected VisualState 并在其中添加以下 XAML 代码以更改颜色:

    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="myback" Storyboard.TargetProperty="Background">
        <DiscreteObjectKeyFrame KeyTime="0" Value="Red" />
    </ObjectAnimationUsingKeyFrames>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 2020-08-29
      相关资源
      最近更新 更多