有没有其他选择 在WPF中

问题描述 投票:0回答:1

在WPF中是否有任何替代选项,此标记的性质是在执行任何特定操作之前启用确认对话框。

这个标签在silverlight支持下,但不幸的是,它似乎在WPF下失踪了。不确定这个Prism团队是否意外地错过了什么。上述标签的最佳替代方案是什么?

wpf silverlight prism prism-4
1个回答
1
投票

你基本上必须创建自己的。但是,有一个例子,我发现之前我找到了一个人。我修改了Prism的交互类很多,所以我的ModalPopupAction可能与你需要的有点不同。所以请查看此链接并下载他的示例。它有WPF的实现!

Prism: InteractionRequest and PopupModalWindowAction for WPF applications

如果你想知道......我的ModalPopupAction看起来像这样(但它需要我的其他一些类)

public class ModalPopupAction : TriggerAction<FrameworkElement>
{
    public UserControl InteractionView
    {
        get { return (UserControl)GetValue(InteractionViewProperty); }
        set { SetValue(InteractionViewProperty, value); }
    }

    // Using a DependencyProperty as the backing store for PopupDialog.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty InteractionViewProperty =
        DependencyProperty.Register("InteractionView", typeof(UserControl), typeof(ModalPopupAction), new UIPropertyMetadata(null));

    protected override void Invoke(object parameter)
    {
        InteractionRequestedEventArgs args = parameter as InteractionRequestedEventArgs;

        if (args == null)
            return;

        // create the window
        ModalPopupDialog dialog = new ModalPopupDialog();
        dialog.Content = InteractionView;

        // set the data context
        dialog.DataContext = args.Interaction;

        // handle finished event
        EventHandler handler = null;
        handler = (o, e) =>
        {
            dialog.Close();
            args.Callback();
        };
        args.Interaction.Finished += handler;

        // center window
        DependencyObject current = AssociatedObject;
        while (current != null)
        {
            if (current is Window)
                break;
            current = LogicalTreeHelper.GetParent(current);
        }
        if (current != null)
            dialog.Owner = (current as Window);

        dialog.ShowDialog();
        dialog.Content = null;
        dialog.DataContext = null;
        args.Interaction.Finished -= handler;
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.