Prism V2 Tour (3)

Source: Internet
Author: User

The article introduces the basic application of region, and this article goes on to introduce the related application of region-regionadapter

1. Pre-implementation mapping relationship Regionadaptermappings

Regionadaptermappings a mapping of control and Regionadapter, which is done in the bootstrapper bootstrapper.

Protected virtual regionadaptermappings configureregionadaptermappings ()
{
regionadaptermappings Regiona      Daptermappings = container.tryresolve<regionadaptermappings> ();
if (regionadaptermappings!= null)
{
regionadaptermappings.registermapping (typeof (Selector), this.        Container.resolve<selectorregionadapter> ());
Regionadaptermappings.registermapping (typeof (ItemsControl), this.        Container.resolve<itemscontrolregionadapter> ());
Regionadaptermappings.registermapping (typeof (ContentControl), this.      Container.resolve<contentcontrolregionadapter> ());
return
regionadaptermappings;
}

Here are three kinds of control support, also explained in the previous article. Regionadapter must implement Iregionadapter interface

2. Find Regionadapter when registering region

<stackpanel cal:regionmanager.regionname= "Mainregion"/>

The above definition is wrong because the mapping relationship between StackPanel and Regionadapter cannot be found in regionadaptermappings. The settings for the attached properties will attempt to execute the following code

Protected virtual Iregion createregion (DependencyObject targetelement, string regionname)
{
//build the region  
Iregionadapter regionadapter = this.regionAdapterMappings.GetMapping (Targetelement.gettype ());
Iregion region = Regionadapter.initialize (targetelement, regionname);
return region;
}

To support StackPanel, we can try to define a regional adapter that implements Iregionadapter for StackPanel.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.