views:

1193

answers:

1

Hi,

In my application I only need one view visible at a time which is why I am using a ContentControl in my shell. The issue is that if I have one view visible (lets say View1) and I activate View2, everything is fine up to this point. Now the user presses the Close button on View2 after which the users end up looking at a blank screen now since no views are active now. I suppose that the region adapter Deactivates the currently active view before activating the next view.

How can I ensure that the previously active view becomes Activated again (View1 from my example)? Do I need a different type of region to achieve this functionality?

Thanks in advance,

Ali

+1  A: 

Unfortunately (as you found out) this is not the behavior. You'll have to track your views and activate the previous one yourself.

Jeremiah commented and made me think about a behavior for this. I think the ActiveAware behavior is probably a good model for a behavior that would track active / inactive events and possibly act on them.

Here's the source code for the ActiveAware behavior. You could use this model as a starting point for a behavior that does what you want, I'm pretty sure. http://compositewpf.codeplex.com/SourceControl/changeset/view/26112#496678

Anderson Imes
This is how I currently do it. Do you think a custom region adapter/behavior would be a good fit for something like this?
Jeremiah Morrill
Good suggestion. I'll post something that might be a good starting point. I think the ActiveAware behavior is very close in logic.
Anderson Imes
Jeremiah, what method are you using to track this right now? Espeically how are you handling views that exist in other modules? If one view in Module1 is deactivated, the previous one may exist in Module2. Event aggregation or some sort of Service? Ultimately who manages the list of views? Thanks for your suggestions, I'll also check out Anderson's idea.
Ali