C# 如何在单击按钮时清除wpf xam数据网格中某些列上应用的过滤器
我想在按钮上单击在我的wpf xam数据网格中的某些列上应用的任何过滤器都应该清除。 我想要像这样的东西 recordfilter.clear 但我不能在RecordFilterChanged事件之外使用它C# 如何在单击按钮时清除wpf xam数据网格中某些列上应用的过滤器,c#,.net,wpf,xaml,xamdatagrid,C#,.net,Wpf,Xaml,Xamdatagrid,我想在按钮上单击在我的wpf xam数据网格中的某些列上应用的任何过滤器都应该清除。 我想要像这样的东西 recordfilter.clear 但我不能在RecordFilterChanged事件之外使用它 所以,如果我能做一些类似于按钮点击事件的事情来解决我的问题。最后,我通过创建xamDataGrid的行为来解决这个问题。下面的代码解决了我的问题 public static readonly DependencyProperty IsFiltersClearedProperty = Depe
所以,如果我能做一些类似于按钮点击事件的事情来解决我的问题。最后,我通过创建xamDataGrid的行为来解决这个问题。下面的代码解决了我的问题
public static readonly DependencyProperty IsFiltersClearedProperty = DependencyProperty.Register("IsFiltersCleared", typeof(bool), typeof(XamDataGridClearFilters), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, ClearFilters));
public bool IsFiltersCleared
{
get { return (bool)GetValue(IsFiltersClearedProperty); }
set { SetValue(IsFiltersClearedProperty, value); }
}
private static void ClearFilters(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (!(bool)e.NewValue)
{
return;
}
XamDataGridClearFilters gridExtender = (XamDataGridClearFilters)d;
XamDataGrid dataGrid = (XamDataGrid)gridExtender.AssociatedObject;
dataGrid.ClearCustomizations(CustomizationType.RecordFilters);
gridExtender.IsFiltersCleared = false;
}
}
请出示一些代码,并解释您在哪里卡住了。谁投票支持这个问题?请立即阅读更新的问题嗨,不幸的是,您提供的信息不足以重现您的情景。请与我们分享您是如何进行自定义筛选的?是否正在使用RadGridView.FilterDescriptors.Clear;当您以编程方式清除过滤器时?