I am in a project that following this post: http://es.infragistics.com/community/blogs/andrew_smith/archive/2010/01/12/itemssource-for-xamdockmanager-elements.aspx has a ContentPane factory.
We have an object associated to each ContentPane.
We need to know which Content Tabs are visible at a given moment. Not necesarilly selected but in View. After some research I found the proprety SelectedItem of the TabGroupPane. At a given time it seems to have the Item that is selected in the TabGroupPane, whether or not the TabGrouPane is focused.
This property is not exactly what I need. I noticed that the Loaded and Unloaded methods would serve my purpose, and it works fine during the run time.
But, when for example, I create 2 controls (ContentPane) from the begining of the application. In the debugger the "Loaded" method gets called for both panes. But the Unloaded method doesn't get called at all. Although just one of the Panes on the TabGroupPane is on the top.
I find this really confusing. I need the Unloaded method to get called at the begining. Or other way to know for all the Panes whether or not are selected in a given moment.
I will appreciate any advice you can offer me.
Regards,
What you are observing is how the WPF framework works. The TabGroupPane is just a derived TabControl and you would see the same thing with that and the TabItems that are in the ItemsControl that are not the selected tabitem. Basically what is happening is that because the ContentPanes are within the LogicalTree they are receiving the initial broadcasted Loaded event. Perhaps one thing you might do is to use that Loaded event, start an asynchronous callback (e.g. Dispatcher.BeginInvoke) and then check the IsLoaded of the element/pane. Another option might be to use the IsVisible property in conjunction with the IsVisibleChanged event.
Thanks Andrew!
I am still starting in WPF, and some things I don't know. Thanks for the explanation.
I tested using IsVisibleChanged as you suggested and it worked like a charm.
Thanks again!