Hi,
I have DataGrid in WPF and I set columns size in XAML.
<Viewbox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" VerticalAlignment="Top"><DataGrid Name="tabulka" Margin="10"><DataGrid.Columns><DataGridTextColumn Header="PB" Width="100" /><DataGridTextColumn Header="A" Width="100"/><DataGridTextColumn Header="Kusů" /><DataGridTextColumn Header="Vloženo" /></DataGrid.Columns></DataGrid></Viewbox>
Items source for DataGrid is List<>. It looks like this:
class Bedna{ //list<> declaration for items
public string PB { get; set; }
public string A { get; set; }
public int Kusu { get; set; }
public int Vlozeno { get; set; }
}
List<Bedna> bedny = new List<Bedna>(); //create list
bedny.Add(new Bedna() { //add items to list
PB = "PB test",
A = "A test",
Kusu = 5,
Vlozeno = 2
});
tabulka.ItemsSource = bedny; //and display themBut when I run it, instead of using the existing columns with setted width, it created some new ones with width as small as possible. Cannot post images or links, so http : // goo . gl / nDnhPS
How to make it to use existing columns iinstead of creating new ones?
Thanks