0

WPFで利用可能な代替手段はありますか?このタグの性質は、特定のアクションを実行する前に表示される確認ダイアログを有効にすることです.

このタグは Silverlight でサポートされていますが、残念ながら WPF では欠落しているようです。この Prism チームが誤って見逃したものがあるかどうかはわかりません。上記のタグに代わる最良の方法は何ですか?

4

1 に答える 1

1

基本的には自分で作成する必要があります。しかし、私が以前に見つけた、それを作った人の例があります。Prism の Interaction クラスをかなり変更したため、ModalPopupAction は必要なものとは少し異なる場合があります。代わりに、このリンクをチェックして、彼の例をダウンロードしてください。WPFの実装があります!

Prism: WPF アプリケーションの InteractionRequest と PopupModalWindowAction

そして、あなたが疑問に思っている場合に備えて...私の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;
    }
}
于 2013-06-28T13:35:51.253 に答える