2017-01-22 14 views
1

WPF data gridWPF DataGridの背景

wpf datagridの背景色を設定するにはどうすればよいですか? DataGridにはいくつかの行だけがあり、行の下に空のスペースがあります。

<DataGrid x:Name="dataGrid" 
        ItemsSource="{Binding ReferentViewModels }"     
        SelectedItem="{Binding SelectedReferentViewModel}" 
        VerticalAlignment="Top" 
        AutoGenerateColumns="False" 
        IsReadOnly="true" 
        SelectionMode="Single" 
        SelectionUnit="FullRow" 
        Margin="0,0,0,0" 
        Height="NaN"      
        Background="Aqua" 
        > 
     <DataGrid.Columns> 
      <DataGridTextColumn Header="Naziv" MinWidth="200" Width="0.25" Binding="{Binding Name}"/> 
      <DataGridTextColumn Header="Opis" MinWidth="100" Width="*" Binding="{Binding Description}"/> 
     </DataGrid.Columns> 

    </DataGrid> 

また、シンプルなスタイルが適用されます:

<Style TargetType="{x:Type DataGrid}"> 
    <Setter Property="AlternatingRowBackground" Value="Azure" /> 
    <Setter Property="HeadersVisibility" Value="All" /> 
    <Setter Property="RowHeaderWidth" Value="20" /> 
    <Setter Property="CanUserResizeRows" Value="False" /> 
</Style> 

は私がbackgroundプロパティを試みたが、この灰色の領域の色を設定する方法ここで

は私のコードです(上の画像を参照してください)動いていない。

+0

DataGridの背後には何がありますか?これは、DataGridのVerticalAlignmentプロパティをTopに設定しているため、おそらくこのパネルの色です。それ以外の場合、Backgroundプロパティを設定する必要があります。 – mm8

+0

あなたは正しいです。データグリッドの背後にはグリッドパネルがあり、背景はグレーに設定されています。ありがとうございました。 –

答えて

1

DataGridの背後には何がありますか?これは、DataGridのVerticalAlignmentプロパティをTopに設定しているため、おそらくこのパネルの色です。それ以外の場合、Backgroundプロパティを設定する必要があります。

関連する問題