
{"id":997,"date":"2012-05-22T14:46:27","date_gmt":"2012-05-22T18:46:27","guid":{"rendered":"http:\/\/www.ikriv.com\/blog\/?p=997"},"modified":"2012-05-22T14:46:27","modified_gmt":"2012-05-22T18:46:27","slug":"prism-region-manager-and-contentpresenter","status":"publish","type":"post","link":"https:\/\/ikriv.com\/blog\/?p=997","title":{"rendered":"Prism Region Manager and ContentPresenter"},"content":{"rendered":"<p>Very brief note, so I don&#8217;t forget the circumstances: I may write a sample later. When you define Prism region in your view like this:<\/p>\n<p><code>&lt;igDock:TabGroupPane prism:RegionManager.RegionName=\"SomeRegion\" \/&gt;  <\/code><\/p>\n<p>Prism has two-staged process that brings your region to existance. First it needs to create a <code>Region<\/code> object, this is done by <code>DelayedRegionCreationBehavior<\/code>. Then it attaches your region to a region manager in <code>RegionManagerRegistrationBehavior<\/code>. The $1M question is: what region manager? To answer that, Prism walks up the logical tree to find a parent view with an already attached region manager (e.g. the shell).<\/p>\n<p>The trouble is, if there is a <code>ContentPresenter<\/code> in the way, it won&#8217;t work. Experiment shows that <code>ContentPresenter<\/code> adds its child to the visual tree, but not to the logical tree. See also <a href=\"http:\/\/social.msdn.microsoft.com\/Forums\/en\/wpf\/thread\/2323e907-7d12-4ae1-b54d-c8c1cda01ae1\">here<\/a>. So, the region manager instance won&#8217;t be found, and the region object will be created, but not added to any region manager. <a style=\"display:none\" href=\"http:\/\/www.codeproject.com\/script\/Articles\/BlogFeedList.aspx?amid=1181663\" rel=\"tag\">CodeProject<\/a><\/p>\n<p>The program will continue without error until you actually try to access that region.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Very brief note, so I don&#8217;t forget the circumstances: I may write a sample later. When you define Prism region in your view like this: &lt;igDock:TabGroupPane prism:RegionManager.RegionName=&#8221;SomeRegion&#8221; \/&gt; Prism has <a href=\"https:\/\/ikriv.com\/blog\/?p=997\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[4,12],"tags":[],"class_list":["entry","author-ikriv","post-997","post","type-post","status-publish","format-standard","category-hack","category-wpf"],"_links":{"self":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/997","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=997"}],"version-history":[{"count":0,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/997\/revisions"}],"wp:attachment":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}