Oct 7, 2011 at 10:47 PM
Edited Oct 7, 2011 at 10:50 PM
I've been looking everywhere for a full and complete code example that demonstrates using scoped regions and tabs. All I can find are snippets of code which simply isn't helping me get the entire picture.
* Prism/WPF 4, MVVM, Event Aggregator
(the short story)
In short I'm trying to get a single view to show up on multiple tabs, think a single customer record on each tab. Plus I want to show other types of views on tabs, not just customers.
(the longer story)
The scenario I'm trying to sort out is:
I have a shell with a tabbed control, region name = Workspace.
I load a HomePage module that injects a view into Workspace and has a nested ItemControl region for HomePageItems - No problem.
I load a Customer module with MEF that has a HomePageItemView that I inject into the HomePageItems region - No problem.
That view has a button which when clicked, raises an event subscribed to by my event service - No problem.
That event service gets the event, generates a GUID (my session key) and raises another event with that session key as the payload - No problem.
My Customer module has a controller class that subscribes to and gets the event. Then it injects a new instance of the CustomerWorkspace view into the Shell's Workspace region, this shows up as a new tab as it should - No problem.
In the UI, I click back to the HomePage tab, click the Customer.HomePageItemView button again, events are handled properly and my Customer controller gets the event asking it to create another customer workspace (this is what I want, a new tab everytime
I load a new customer view). This is where it doesn't work.
At that point I get the expected "View already exists" error which I understand. I inject the prism RegionManager into the Customer module and know I can't add a view with the same name to the RegionManager twice.
My probelm is in trying to figure out where to use scoped regions.
A working code example (not just the 5 lines on how to overload the Region.Add() method to return a new regionmanager) would really help.
I tried reviewing the Stock TRader RI but that both uses Unity and is way overkill with indirection that I don't care to figure out at this time. Plus, I don't see any use of scoped regions there nor does it use tabs.
Anyways, at this point I'm hoping to find some good sample projects if anyone knows of anything.
Otherwise I'll keep posting more detail about this since I simply can't seem to get it working.