Share via


DataGrid.AlternatingRowBackground 屬性

定義

取得或設定用於交替列的背景筆刷。

public:
 property System::Windows::Media::Brush ^ AlternatingRowBackground { System::Windows::Media::Brush ^ get(); void set(System::Windows::Media::Brush ^ value); };
public System.Windows.Media.Brush AlternatingRowBackground { get; set; }
member this.AlternatingRowBackground : System.Windows.Media.Brush with get, set
Public Property AlternatingRowBackground As Brush

屬性值

Brush

Brush,繪製每第 n 個資料列的背景,其中 n 由 AlternationCount 屬性所定義。 已註冊的預設值是 null。 如需哪些因素會影響值的詳細資訊,請參閱 DependencyProperty

範例

下列範例示範如何在 上 DataGrid 設定替代的資料列背景色彩。

<DataGrid x:Name="CustomerGrid" ItemsSource="{Binding}" AlternatingRowBackground="LightBlue" AlternationCount="2" />

下圖顯示此程式碼在執行時的外觀。

資料列背景的三種替換色彩

備註

AlternatingRowBackgroundRowBackgroundAlternationCount 屬性會一起決定每個資料列背景的外觀。

如果 AlternationCount 小於 2,請將 AlternatingRowBackground 屬性設定 AlternationCount 為 2。

適用於

另請參閱