Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Master Detail relations in WPF XAML

$
0
0

I'm trying to make a Master/Detail relationship between a ComboBox and a DataGrid.

In my DataSet I have 2 tables and a Relation between the two.

I set the DataContext of my Window in XAML to a ViewModel class.

I set the ItemsSource of the ComboBox to a BindingListCollectionView    (ItemsSource="{Binding TheBLCV}").

I can get the DataGrid to correctly display the rows corresponding to the selection in the ComboBox if I set the DataGrid's ItemsSource in code behind with this:

 

Binding bnd;
bnd = new Binding("TheRelation");
bnd.Source = TheBLCV;
TheDataGrid.SetBinding(.....ItemsSourceProperty, bnd);

But, I want to do the binding of the DataGrid in XAML and not code behind. I just cant figure our the syntax. When I do it in the code behind, the Binding's source is the same BindingListCollectionView as the ComboBox and the Binding's Path is the name of the Relation. But I don't know how to do it in XAML. Somehow I have to tell the ItemsSource to use the same BLCV but the path should be the Relation

Michael


Viewing all articles
Browse latest Browse all 18858

Trending Articles