WPF - Prism - 激活和停用 ContentControl 区域中的视图

发布于 2024-08-06 21:59:50 字数 278 浏览 7 评论 0原文

在我的应用程序中,我一次只需要一个可见的视图,这就是我在 shell 中使用 ContentControl 的原因。问题是,如果我有一个可见视图(比如说 View1)并且我激活了 View2,那么到目前为止一切都很好。现在,用户按下 View2 上的“关闭”按钮,之后用户最终会看到一个空白屏幕,因为现在没有活动的视图。我认为区域适配器在激活下一个视图之前停用当前活动的视图。

如何确保之前的活动视图再次激活(我的示例中的 View1)?我是否需要不同类型的区域来实现此功能?

预先感谢,

阿里

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

累赘 2024-08-13 21:59:50

不幸的是(正如您所发现的)这不是行为。您必须跟踪您的视图并亲自激活前一个视图。

耶利米的评论让我思考了一个行为。我认为 ActiveAware 行为可能是一个很好的模型,可以跟踪活动/非活动事件并可能对它们采取行动。

以下是 ActiveAware 行为的源代码。我很确定,您可以使用此模型作为执行您想要的行为的起点。
http://compositewpf.codeplex.com/SourceControl/changeset/view/26112# 496678

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文