Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Adding the logic of "An Extended WPF TabControl" to the next release?

$
0
0
Hi,

Based on my understanding, the default implementation of TabControl in WPF inherits from Selector type. Therefore, Prism provides a specific region adapter for selectors, called SelectorRegionAdapter.

  • The SelectorRegionAdapter is in charge of creating the region, wiring up to the selector (in this case, your TabControl), and attach the SelectorItemsSourceSyncBehavior behavior.
  • The SelectorItemsSourceSyncBehavior is in charge of subscribing to the region events in order to react upon them and synchronize the Selector items with the region Views. The following code describes how this behavior add items to your Selector when Views are added to the region.
privatevoid Views_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
    if (e.Action == NotifyCollectionChangedAction.Add)
    {
        int startIndex = e.NewStartingIndex;
        foreach (object newItem in e.NewItems)
        {
            this.hostControl.Items.Insert(startIndex++, newItem);
        }
    }
...
}
As you can see, when a View is added to the region, and that region is a Selector, a new item is added to the selector corresponding to that View.

You can find those classes in the Prism Library, under the namespaces Microsoft.Practices.Prism.Regions and Microsoft.Practices.Prism.Regions.Behaviors.

Hope this helps,

Federico Martinez
http://blogs.southworks.net/fmartinez

Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>