在 Windows 10 UWP 中显示 ListView 项目的默认背景颜色?

Display default background color of ListView Item in Windows 10 UWP?

我正在处理 Windows 10 ListView,我想将 ListView 项目的默认背景色显示为白色,然后 select 然后显示为灰色。我尝试遵循 Style 但它没有将默认设置为白色。它在 selected.

时有效
<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>

BackgroundTemplate 是分开的。在 ListViewItemPresenter 中添加所有相关样式的好习惯。希望有帮助

<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>