【问题标题】:Can't filter a Detail-table which is bound to a Master-table with rowfilter?无法使用 rowfilter 过滤绑定到 Master-table 的 Detail-table?
【发布时间】:2015-07-07 09:28:35
【问题描述】:

如果我想过滤一个详细信息表(显示在 DataGrid 中),例如使用以下内容:DSHistory.TBL_MATERIAL.DefaultView.RowFilter = string.Format("MAT_NAME LIKE '%{0}%' AND MAT_FK_LFR_ID = {1}",TextBoxSearch.Text, ComboBoxLieferant.SelectedValue); 只有当我在事件中将 DataGrid 的 ItemsSource 显式更改为:dg1.ItemsSource = DSHistory.TBL_MATERIAL; 时才有效,但是那么绑定将不再起作用(在 page_loaded 中我添加了这样的 DataContext:this.DataContext = DSHistory.TBL_LIEFERANTENSTAMM;,当然还绑定了 XAML 中的主表和详细表:<ComboBox Name="ComboBoxLieferant" ItemsSource="{Binding}" DisplayMemberPath="LFR_NAME" IsSynchronizedWithCurrentItem="True" SelectionChanged="ComboBoxLieferant_SelectionChanged" /> 和 <DataGrid Name="dg1" ItemsSource="{Binding Path=FK_TBL_MATERIAL_TBL_LIEFERANTENSTAMM}" IsSynchronizedWithCurrentItem="True">

有没有办法在不“破坏”绑定的情况下进行这样的过滤?

感谢您的帮助!

【问题讨论】:

    标签: wpf binding master-detail rowfilter


    【解决方案1】:

    我自己解决了这个问题。 我创建了一个过滤器类,我在其中创建了一个 BindingListCollectionView。 然后我可以很容易地用 customfilter 过滤这个视图。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-22
      • 1970-01-01
      • 2014-10-26
      相关资源
      最近更新 更多