Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turning a WPF DataGrid background image on and off?

Tags:

c#

.net

wpf

xaml

I have a DataGrid which, when empty, I wish to display a background image. When the DataGrid is populated I wish for the image to disappear, and reappear if the DataGrid is cleared again.

Is this possible either through XAML or C#?

like image 406
Tony Avatar asked Oct 05 '22 21:10

Tony


1 Answers

if(myDataGridView.Rows.Count == 0) {

dataGrid.Background = new ImageBrush("exampleImage.png");

}

else {

// it is not empty 

}
like image 133
dsgriffin Avatar answered Oct 13 '22 11:10

dsgriffin