-2

i have that code in my desktop application that fill the datagrid from mysql database

var mA = new MySql.Data.MySqlClient.MySqlDataAdapter("SELECT * FROM items", DataHolder.MySqlConnection);
var mT = new System.Data.DataTable();
mA.Fill(mT);
dataGrid.ItemsSource = mT.DefaultView;

but i can't figure out how to bind it to change certain cells in certain column to change it's background color when it's equl to certain values.

I have read Change DataGrid cell colour based on values, but in my case there is no columns to bind in the Data Grid until the code is executed. What I am asking is "how to make it work with that"?!

Community
  • 1
  • 1

1 Answers1

0

i know how to change the background color for datagrid that already have columns in it but in that case there isn't no columns to bind in the datagrid until the code is executed

This implies that you are using the auto generated columns. You just need to hook AutoGeneratingColumn or AutoGeneratedColumns, which give you access to the new columns in the event args, which you then can style accordingly (would recommend defining styles in XAML resources somewhere).

H.B.
  • 166,899
  • 29
  • 327
  • 400