显示使用Prism 4模态对话框 [英] Displaying modal dialogs using PRISM 4

查看:983
本文介绍了显示使用Prism 4模态对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用棱镜和MVVM一个.NET 4.0应用程序,以及WPF。

I'm developing a .NET 4.0 application using PRISM and MVVM, as well as WPF.

我现在有细分区域的一个外壳,在其中插入了意见。当用户点击其中一个视图按钮,我想一个特制的模态对话框要对所有的意见顶部显示,但仍然在相同的外壳。

I currently have a shell subdivided in regions, with views inserted in them. When the user clicks on a button in one of the views, I would like a custom-made modal dialog to be displayed on top of all the views, but still within the same shell.

我看着StockTrader RI为例,其执行RegionPopupBehavior的。基本上,他们创造了一个依赖属性,使它们能够与特定的,定制的行为界定的区域。该行为是一个负责处理它相关的视图的渲染,因此显示它作为一个弹出窗口。

I looked at the StockTrader RI example and their implementation of the RegionPopupBehavior. Basically, they created a dependency property which allows them to define regions with a specific, custom-made behavior. The behavior is the one in charge of handling it's associated view's rendering, hence displaying it as a popup window.

唯一的缺点这种方法是,所有其他的意见仍然有效,所以在弹出的不是模式。我想这可以通过手动禁用所有非必要区域的外壳来解决,但我不知道如何干净,这是。

The only downside to this approach is that all the other views are still active, so the popup isn't modal. I guess this can be resolved by manually disabling all un-needed regions in the shell, but I'm not sure how "clean" this is.

我在想,如果有一个更好,更简单的方法,以在棱镜显示模式弹出的看法?

I was wondering if there were a better and simpler approach to displaying modal pop-up views in Prism ?

推荐答案

您可能会感兴趣的一个自定义的 PopupUserControl 我已经贴在我的博客,其行为之类的。

You might be interested in a custom PopupUserControl I have posted on my blog that behaves like that.

通常我用这样的:

<local:PopupPanel 
    Content="{Binding PopupContent}"
    local:PopupPanel.PopupParent="{Binding ElementName=SomeParentPanel}"
    local:PopupPanel.IsPopupVisible="{Binding IsPopupVisible}">

    <local:PopupPanel.Resources>
        <DataTemplate DataType="{x:Type local:SomeViewModel}">
            <local:SomeView />
        </DataTemplate>
        <DataTemplate DataType="{x:Type local:DifferentViewModel}">
            <local:DifferentView />
        </DataTemplate>
    </local:PopupPanel.Resources>

</local:PopupPanel>

虽然你也可以只写在弹出的​​内容,而不是具有约束力的内容属性

Although you can also just write the Content in the popup instead of binding the Content property

<local:PopupPanel 
    local:PopupPanel.PopupParent="{Binding ElementName=SomeParentPanel}"
    local:PopupPanel.IsPopupVisible="{Binding IsPopupVisible}">

    <Border BorderBrush="Blue" BorderThickness="2">
        <local:MyUserControl />
    </Border>
</local:PopupPanel>

这篇关于显示使用Prism 4模态对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆