I'm currently working on a dynamic DataGrid in WPF, so I create a DataTable directly in the ViewModel, and I bind it to my view :
<DataGrid Grid.Row="1" ItemsSource="{Binding DataTable.DefaultView}" AutoGenerateColumns="True" />
But I don't know how to change the properties like HorizontalAlignment in the C# code. I would like to set the HorizontalAlignment to Center for my Column1.
I've this code to create the DataTable :
DataTable dataTable = new DataTable();
dataTable.Columns.Add(new DataColumn("Column1"));
And this one to add rows :
DataRow row = datatable.NewRow();
row["Column1"] = myvalue;
datatable.Rows.Add(row);
Do I have to set properties in the XAML or in the C#, and how do I do?