Problem beim Binden von DataGridComboBoxColumn.ItemsSource
Ich habe 3 Tabellen: Item - das ist der DataContext - hat eine Navigationsspalte Group Group - hat eine Navigationsspalte Category.
Ich möchte im DataGrid beide Spalten (Kategorie & Gruppe) haben und wenn ich eine Kategorie auswähle, sollte sie in der Gruppenspalte nur die Category.Groups anzeigen.
Hier ist der Code, an dem ich arbeite:
<tk:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding}">
<tk:DataGrid.Columns>
<!--Works-->
<tk:DataGridComboBoxColumn
Header="Categroy"
DisplayMemberPath="Title"
SelectedValuePath="CategoryId"
SelectedValueBinding="{Binding Group.Category.CategoryId}"
ItemsSource="{Binding Context.Categories,
Source={x:Static Application.Current}}"
/>
<!--Look at these two things:-->
<!--This does work-->
<tk:DataGridTemplateColumn>
<tk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ItemsControl
ItemsSource="{Binding Group.Category.Groups}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type data:Group}">
<TextBlock Text="{Binding Title}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</tk:DataGridTemplateColumn.CellTemplate>
</tk:DataGridTemplateColumn>
<!--But this does NOT work, even it's the same source-->
<!--Notice I even tried a dummy converter and doesnt reach there-->
<tk:DataGridComboBoxColumn
Header="Group"
DisplayMemberPath="Title"
SelectedValuePath="GroupId"
ItemsSource="{Binding Group.Category.Groups,
Converter={StaticResource DummyConverter}}"
SelectedValueBinding="{Binding Group.GroupId}"
/>
</tk:DataGrid.Columns>
</tk:DataGrid>
Aktualisieren
Würden Sie sagen, dass das Problem darin besteht, dass die ItemsSource-Eigenschaft nicht auf eine nicht statische Bindung festgelegt werden kann? Ich vermute schon, weil ich die ItemsSource auf gesetzt habe{Binding}
mit demDummyConverter
es hört im Konverter nicht auf; und in der Kategorie ComboBox funktioniert es einwandfrei.