Thanks to Danny Beckett for translating @MohammedAFadil's XAML response converted to C # code. All my datagrids are dynamically configured, so I can change something whenever I want.
To set an empty datagrid, there is nothing in it, and then just bind it to the data, just take your datagrid.columns
var centerTextSetter = new Style(typeof(DataGridCell)) { Setters = { new Setter(TextBlock.TextAlignmentProperty, TextAlignment.Center) } }; DgDbNames.Columns.Add(new DataGridTextColumn() { Header = "Db Name", Binding = new System.Windows.Data.Binding("DbName"), IsReadOnly = true, Width = new DataGridLength(0.2, DataGridLengthUnitType.Star), CellStyle = centerTextSetter });
Stephen Himes Oct 18 '17 at 20:07 on 2017-10-18 20:07
source share