开发者

WPF - Prism - Activate and Deactivate views in a ContentControl region

开发者 https://www.devze.com 2022-12-08 02:20 出处:网络
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, every

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 be开发者_如何学运维fore 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号