2016-11-12 68 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

不客氣:-)!快樂的編碼! –