Hi, I'm trying to use the filter icon on a XamDataGrid in an unconventional way. I want NOTHING to display in the drop down list when you click the filter icon. I can do this via the RecordFilterDropDownOpening event and clearing the drop down items collection but the white box still displays where the values would have been. I don't want this white box to display at all. I simply want to display my own filter dialog when someone clicks on the filter icon. Is this possible? Thanks in advance.
Hello Jerome,
Thank you for your post!
To achieve your requirement, I would recommend continuing to handle the RecordFilterDropDownOpening event, but also to subscribe to the PreviewMouseDown event on the FilterButton in the XamDataGrid. You can do this via a style for FilterButton and using an EventSetter to hook into the PreviewMouseDown event. This event will fire prior to the RecordFilterDropDownOpening event. In the handle for the PreviewMouseDown event, I would recommend casting the sender to a FilterButton object, and then use the Infragistics Utilities class to get a XamComboEditor from the FilterButton by using the static GetDescendantFromType method. You should store this XamComboEditor as a global element, as it will be used in the RecordFilterDropDownOpening event, since this XamComboEditor is where the drop down items are coming from.
In the RecordFilterDropDownOpening event, you can utilize the XamComboEditor mentioned above, and set it's IsDropDownOpen event to false. Then, display your custom dialog. I have attached a sample project to demonstrate the above.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
For some strange reason
private void OnFilterButtonMouseDown(object sender, MouseButtonEventArgs e) { var filterIcon = (FilterButton)sender; this.latestComboEditor = (XamComboEditor)Utilities.GetDescendantFromType(filterIcon, typeof(XamComboEditor), true); }
yields a null value for latestComboEditor. According to SNOOP there is indeed a XamComboEditor in the FilterIcon so I'm puzzled. Is there something I'm not seeing?
Are you using a different mouse event than the PreviewMouseDown event displayed in the sample I had sent you? If you are using the MouseDown event instead, I could see this happening since that event will not be fired. This is because the MouseDown event for the FilterButton is already marked as handled in the source code of the control. However, by utilizing the PreviewMouseDown event, I cannot seem to reproduce this behavior that you are seeing.
So the problem was that I was using the wrong version of XamComboEditor. I was SUPPOSED to use Infragistics.Windows.Editors.XamComboEditor but I was using Infragistics.Controls.Editors.XamComboEditor. That's why I was getting null. Why on earth there would be two classes by the same name I don't know but after 2 days of frustration I got it figured out.