2016-11-12 74 views

回答

0

这样做有两种方式。

您可以设置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> 

enter image description here

+0

这正是我正在寻找的答案类型。谢谢! –

+0

不客气:-)!快乐的编码! –