有没有办法让uwp中的ListViewItem背景被视为两种不同的颜色,如this control?
答案 0 :(得分:1)
有两种方法可以做到这一点。
您可以设置ListView
本身的背景并在那里设置颜色:
<ListView>
<ListView.Background>
<!-- some background, probably linear gradient brush
with sharp stop between the two colors -->
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="DarkGray" Offset="0.2" />
<GradientStop Color="CornflowerBlue" Offset="0.2" />
</LinearGradientBrush>
</ListView.Background>
</ListView>
另一种方法是分别设置每个项目的背景颜色:
<ListView>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="DarkGray" Offset="0.2" />
<GradientStop Color="CornflowerBlue" Offset="0.2" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>