Search code examples
wpfbindingmaster-detailrowfilter

Can't filter a Detail-table which is bound to a Master-table with rowfilter?


If I want to filter a detail table(shown in a DataGrid) by using for example something like this: DSHistory.TBL_MATERIAL.DefaultView.RowFilter = string.Format("MAT_NAME LIKE '%{0}%' AND MAT_FK_LFR_ID = {1}",TextBoxSearch.Text, ComboBoxLieferant.SelectedValue); it only works if I explicitly change the ItemsSource of the DataGrid to: dg1.ItemsSource = DSHistory.TBL_MATERIAL; in the event, but then the binding won't work any more(in page_loaded I added the DataContext like this: this.DataContext = DSHistory.TBL_LIEFERANTENSTAMM; and of course bind the master- and detail-table in XAML: <ComboBox Name="ComboBoxLieferant" ItemsSource="{Binding}" DisplayMemberPath="LFR_NAME" IsSynchronizedWithCurrentItem="True" SelectionChanged="ComboBoxLieferant_SelectionChanged" /> and <DataGrid Name="dg1" ItemsSource="{Binding Path=FK_TBL_MATERIAL_TBL_LIEFERANTENSTAMM}" IsSynchronizedWithCurrentItem="True">

Is there a way to filter like this without "breaking" the binding?

Thanks for help!


Solution

  • I solved this problem by myself. I created a filter class in which I create a BindingListCollectionView. Then I can easily filter this view with the customfilter.