문제

is there any alternative available for in WPF, nature of this tag is enable the confirmation dialog coming before you execute the any specific action.

this tag supported under silverlight, but unfortunately it seems that missing under WPF. Not sure if something this Prism team accidently missed. What is the best alternative for the above tag?

도움이 되었습니까?

해결책

You basically have to create your own. But, there is an example I found before of someone who made one. I modified Prism's Interaction classes quite a bit, so my ModalPopupAction may be a bit different than what you need. So instead, check out this link and download his example. It has an implementation for WPF!

Prism: InteractionRequest and PopupModalWindowAction for WPF applications

And in case you were wondering... my ModalPopupAction looks like this (but it requires some other classes of mine)

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;
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top