XAM 数据网格更改过滤器下拉列表的顺序

XAM Data Grid change order of filter drop down list

我可以更改过滤器下拉列表的顺序吗? 列表末尾有一个 空白 选项,我必须将它放在第一个位置。

为了解决这个问题,我搜索了正在显示的 TreeView 并重新关联 ItemSource运行。我使用了 XAMDataGridRecordFilterDropDownOpening 事件。

代码:

void DataPresenter_RecordFilterDropDownOpening(object sender, Infragistics.Windows.DataPresenter.Events.RecordFilterDropDownOpeningEventArgs e)
        {
            RecordFilterTreeControl rftc = null;
            try
            {
                rftc = (e.MenuItems[e.MenuItems.Count - 1] as FieldMenuDataItem).Header as RecordFilterTreeControl;
                if (rftc != null)
                {
                    rftc.Loaded += new RoutedEventHandler(rftc_Loaded);
                }
            }
            catch (Exception ex)
            {
                LogInfo.LogToListeners(ex);
            }
            finally
            {
                rftc = null;
            }
        }



void rftc_Loaded(object sender, RoutedEventArgs e)
    {
        TreeView tv = null;
        try
        {
            tv = Infragistics.Windows.Utilities.GetDescendantFromType(sender as DependencyObject, typeof(TreeView), false) as TreeView;
            if (tv != null)
            {

                var newSource = new ObservableCollection<RecordFilterTreeItem>();
                foreach (var item in tv.ItemsSource)
                {
                    if (item is RecordFilterTreeItem)
                    {
                        newSource.Add(item as RecordFilterTreeItem);
                    }
                }
                if (newSource[newSource.Count - 1].DisplayText == "(Blanks)")
                {
                    newSource.Move(newSource.Count - 1, 1);
                }
                tv.ItemsSource = newSource;// this will give a new itemsource to treeview


            }
        }
        catch (Exception ex)
        {
            LogInfo.LogToListeners(ex);
        }
        finally
        {
            tv = null;
        }
    }

结果: