Can I change the order of filter drop down list. There is a blank option at the end of the list I've to put it at very first position.
To solve this I searched for the TreeView
that is being displayed and reassociate the ItemSource
at runtime. I have used RecordFilterDropDownOpening
event of XAMDataGrid
.
CODE:
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;
}
}
Result: