I would like to display my object database in a DataGrid
public class Student { public string Imie { get; set; } public string Nazwisko { get; set; } string Numer { get; set; } internal List<Telefon> Telefony { get; set; } internal Adres Adres { get; set; } }
In Adres and Telefon , I obviously have a few extra fields.
My xaml:
<DataGrid Name="dataGrid" ItemsSource="{Binding Student}" AutoGenerateColumns="False" CellEditEnding="dataGrid_CellEditEnding" CurrentCellChanged="dataGrid_CurrentCellChanged" PreviewKeyDown="dataGrid_PreviewKeyDown"> <DataGrid.Columns> <DataGridTextColumn Header="Imie" Binding="{Binding Imie}"/> <DataGridTextColumn Header="Nazwisko" Binding="{Binding Nazwisko}"/> <DataGridTextColumn Header="Numer" Binding="{Binding Numer}"/> <DataGridTextColumn Header="Ulica" Binding="{Binding Adres.Ulica}"/> <DataGridTextColumn Header="KodPocztowy" Binding="{Binding Adres.KodPocztowy}"/> <DataGridTextColumn Header="Miasto" Binding="{Binding Adres.Miasto}"/> <DataGridTextColumn Header="Tel. Numer" Binding="{Binding Telefon.Numer}"/> <DataGridTextColumn Header="Tel. Operator" Binding="{Binding Telefon.Operator}"/> </DataGrid.Columns> </DataGrid>
I can easily get and set Imie , Nazvski and Number , but when I try to set the value to Ulica (field in the Adres class) the compiler gives me this exception:
InvalidOperationException was unhandled Two-way binding requires Path or XPath.
Thanks for the help.
source share