Frage

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?

War es hilfreich?

Lösung

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;
    }
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top