我有简单的带绑定的 Datagrid,这个可以正常工作,并且在 RowDetailsRemplate 另一个 Datagrid 中,但在这种情况下绑定不起作用。你能帮我解决这个问题吗?
XAML:
<DataGrid Name="datagrid" Margin="5,0,5,0" GridLinesVisibility="None" CanUserAddRows="False" ItemsSource="{Binding nowy}" >
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Expander Name="expander" IsExpanded="False" Collapsed="sw" Expanded="pos"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<StackPanel>
<DataGrid Name="wz" ItemsSource="{Binding flight_list}"/>
</StackPanel>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
C#:
public ObservableCollection<flight> flight_list { get; set; }
public ObservableCollection<subject> nowy { get; set; }
nowy = new ObservableCollection<subject>() {
{new subject(){ Przedmiot = "J.angielski", Nauczyciel = "B.A.Krawczyk", Sala = "120", Poziom = "Średnio-zaawansowany", Status = "Uczeń"}},
{ new subject(){Przedmiot = "polski", Nauczyciel = "zły", Sala = "130", Poziom = "podstawowy", Status = "gey"}}
};
flight_list = new ObservableCollection<flight>(){new flight(){From = "Warsaw", To = "Florida", schedule = new List<string>(){"12-02-2013", "12-03-2012", "31-2"}}};
DataContext = this;