首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Windows10UWP中显示ListView项目的默认背景色?

在Windows10UWP中显示ListView项目的默认背景色?
EN

Stack Overflow用户
提问于 2016-06-01 12:21:43
回答 1查看 976关注 0票数 0

我正在使用Windows10 ListView,我希望将ListView项默认背景色显示为白色,然后选择灰色。我试过遵循样式,但它没有将默认设置为白色。它在被选中时起作用。

代码语言:javascript
运行
复制
<Style x:Key="TestListViewContainerStyle"
       TargetType="ListViewItem">
    <Setter Property="HorizontalContentAlignment"
            Value="Stretch" />
    <Setter Property="Margin"
            Value="0,0,0,1"/>
    <Setter Property="Padding"
            Value="0"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ListViewItem">
                <ListViewItemPresenter SelectedBackground="#E9E9E9"
                                       PlaceholderBackground="White"
                                       Background="White"/>

            </ControlTemplate>
        </Setter.Value>
    </Setter>

</Style>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-06-01 13:03:46

BackgroundTemplate是分开的。在ListViewItemPresenter中添加所有相关样式的良好实践。希望这有帮助

代码语言:javascript
运行
复制
<Setter Property="Background" Value="White"/>
<Setter Property="Template">
   <Setter.Value>
    <ControlTemplate TargetType="ListViewItem">
      <ListViewItemPresenter
         ContentTransitions="{TemplateBinding ContentTransitions}"
         SelectionCheckMarkVisualEnabled="True"
          CheckBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
          CheckBoxBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
          DragBackground="{ThemeResource ListViewItemDragBackgroundThemeBrush}"
          DragForeground="{ThemeResource ListViewItemDragForegroundThemeBrush}"
          FocusBorderBrush="{ThemeResource SystemControlForegroundAltHighBrush}"
          FocusSecondaryBorderBrush="{ThemeResource SystemControlForegroundBaseHighBrush}"
          PlaceholderBackground="White"
          PointerOverBackground="{ThemeResource SystemControlHighlightListLowBrush}"
          PointerOverForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}"
          SelectedBackground="#E9E9E9"
          SelectedForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}"
          SelectedPointerOverBackground="{ThemeResource SystemControlHighlightListAccentMediumBrush}"
          PressedBackground="{ThemeResource SystemControlHighlightListMediumBrush}"
          SelectedPressedBackground="{ThemeResource SystemControlHighlightListAccentHighBrush}"
          DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}"
          DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}"
          ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
          HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
          VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
          ContentMargin="{TemplateBinding Padding}"
          CheckMode="Inline"/>
    </ControlTemplate>
  </Setter.Value>
</Setter>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37568516

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档