Jan 29, 2011 at 5:02 AM
Edited Jan 29, 2011 at 6:29 AM
Wow, that looks like a lot of work to just have a region in another window!
In looking through the code, it looks like what they do is create a new region, assign it a custom behavior to it and then add that new region to the Region Manager. (see RegionPopupBehaviors.RegisterNewPopupRegion)
The custom behavior (DialogActivationBehavior) listens for it's Region.ActiveViews.CollectionChanged event to fire. When it sees one, it the take e.NewItems which is the constructed view and creates a window, and sets the Window.Contents to that
view via a wrapper around the window.
OK... I think I see how I could use that for this. What has me wondering if there isn't an easier way, is the comments at the start of RegionPopupBehaviors:
/// Although the fastest way is to create a RegionAdapter for a Window and register it with the RegionAdapterMappings,
/// this would be conceptually incorrect because we want to create a new popup window everytime a view is added
/// (instead of having a Window as a host control and replacing its contents everytime Views are added, as
/// other adapters do). This is why we have a different class for this behavior, instead of reusing the
/// RegionManager.RegionNameProperty attached property.
I don't want a new window every time, I want to replace the contents of my region every time. So I guess I'm off to look at RegionAdapters and how to map them next. Anyone have a good example for me?
Edit: oh... wait, that takes me back to
composite contrib and the WindowRegionAdapter. So I guess I need to finish converting that to 4.0 and see what I get.