The setup is a xamTabControl bound to a collection which has a datatemplate with a xamDataGrid in it. Pretty normal stuff.
The xamTabControl virtualizes the content, reuses the instances inside the template.
The problem behavior is if you set a filter, change the tab then the filter is still as you set it on the first tab. There doesn't seem to be a datasourcechanged event on the xamDataGrid. Is there any events that will fire on the xamDataGrid when the tab is changed?
Jesse
Hello Jesse,
XamTabControl keeps the content of the selected tab in the visual tree. The content of the previously selected tab is removed so that the content of the new one can be displayed. This result in unloaded event occurring for the items in the previous tab and loaded event occurring for the items in the current tab. In this case you may try to use the loaded event for the XamDataGrid and clear the filter collection for the grid’s layout: xamDataGrid1.FieldLayouts[0].RecordFilters.Clear(). If it does not help or you have any other questions, please feel free to ask.
Maria, I don't believe this is the case when the xamTabControl is bound to a collection. In my tests when the tab selection changes the tab contents are NOT disposed and the datasource is changed while the instance is maintained. The loaded event does not fire when the tab selection changes.
An unexpected side effect of this is a filter applied in one tab is maintained when the tab selection changes.
The controls in the tabs are disposed if the controls are set as content of the tabs. I have missed that you are using the grid in DataTemplate which is actually reusing the same instance for different tabs. In this case the loaded event will not fire and the grid will not be notified for the changed tabs. To remove the filters you can handle the SelectionChanged event of the XamTabControl and get the XamTabControl.SelectedContent to find the grid.I hope this will be helpful for you. Please let me know if you have any other questions.
I am just checking if you had a chance to look into this and if you would like any further assistance on the matter.
There's not much else that can be done I guess, I put an idea up for adding a DataSourceChanged event that would help with this situation. If I want to have a behavior in the grid then there's no way for me to unsubscribe from events when the tab changes, I'll only have access to the current datacontext so I won't be able to unsubscribe any events in the old one.
If you use the DataContext to bind the grid to you can use the grid’s DataContextChanged event. You can also add a new product idea for future implementation of a DataSourceChanged event at http://ideas.infragistics.com.
Steps to create your idea: 1. Log into the Infragistics Product Ideas site at http://ideas.infragistics.com (creating a new login if needed).2. Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)3. Add your product idea and be sure to be specific and provide as much detail as possible. Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing!
The benefits of submitting the product idea yourself include:- Direct communication with our product management team regarding your product idea.- Notifications whenever new information regarding your idea becomes available.
Additional benefits of the Product Idea system include:
- Ability to vote on your favorite product ideas to let us know which ones are the most important to you. You will have ten votes for this and can change which ideas you are voting for at any time.- Allow you to shape the future of our products by requesting new controls and products altogether.- You and other developers can discuss existing product ideas with members of our Product Management team.
The product ideas site allows you to track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.