Click here to Skip to main content
15,900,325 members
Articles / All Topics

Prism 2.x Weirdness

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
11 Feb 2012Apache1 min read 10.1K   1  
Prism 2.x Weirdness

Any customer can have a car painted any colour that he wants so long as it is black.” H. Ford

Trying to figure out how scoped region managers would work in Prism. We are still on .NET 3.5, so the highest version we can use is 2.x. They tell you your views may be any dependency objects. With some data templating magic I can add my view model object to a region, and it all just works.

But there are exceptions. Firstly, auto-detecting regions when the view is loaded won’t work unless your view is a FrameworkElement, because DelayedRegionCreationBehavior says so. Well, no big deal.

More trouble comes from RegionManagerRegistrationBehavior when you attach a region name to your control. This behavior assumes that the scoped region manager (or any region manager) would be attached to an ancestor of the control in the logical tree. This would be true if what you added to the region is really the ancestor of the control. However, if what you added to the region was a data object, and the real view (which is the ancestor of the control) was created via data templating, the region manager will be attached to your data object, not to the real view, and the RegionManagerRegistrationBehavior behavior won’t find it. Everything breaks, and you cannot use regions in scoped region managers.

Sorry for an illegible rant, I need to record what I found. More organized details later.

This article was originally posted at http://www.ikriv.com/blog?p=912

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


Written By
Technical Lead Thomson Reuters
United States United States
Ivan is a hands-on software architect/technical lead working for Thomson Reuters in the New York City area. At present I am mostly building complex multi-threaded WPF application for the financial sector, but I am also interested in cloud computing, web development, mobile development, etc.

Please visit my web site: www.ikriv.com.

Comments and Discussions

 
-- There are no messages in this forum --