Skip to content

DevExpress-Examples/wpf-data-grid-customize-background

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WPF Data Grid - Customize Background Color

This example demonstrates how to use the WPF ColorEdit control to customize the background color of grid UI elements.

WPF Data Grid - Customize Background Color, DevExpress

The GridControl.Background property specifies the background color of UI elements such as column headers, the group panel, and the row indicator.

The GridControl.DataAreaBackground property specifies the background color of data cells and group rows.

<dxg:GridControl Grid.Column="0"
                    Background="{Binding SelectedColor, Converter={dxmvvm:ColorToBrushConverter}}"
                    DataAreaBackground="{Binding DataAreaSelectedColor, Converter={dxmvvm:ColorToBrushConverter}}"
                    ItemsSource="{Binding Items}"
                    AutoGenerateColumns="AddNew" Grid.ColumnSpan="3">
    <dxg:GridControl.View>
        <dxg:TableView EnableSelectedRowAppearance="False"/>
    </dxg:GridControl.View>
</dxg:GridControl>
public class MainViewModel : ViewModelBase {
    public Color SelectedColor {
        get { return GetProperty(() => SelectedColor); }
        set { SetProperty(() => SelectedColor, value); }
    }

    public Color DataAreaSelectedColor {
        get { return GetProperty(() => DataAreaSelectedColor); }
        set { SetProperty(() => DataAreaSelectedColor, value); }
    }

    public virtual ObservableCollection<Employee> Items {
        get { return GetProperty(() => Items); }
        set { SetProperty(() => Items, value); }
    }
    public MainViewModel() {
        Items = Stuff.GetStuff();
    }
}

Documentation