Exemplo n.º 1
0
        private void contentRendered(object sender, EventArgs e)
        {
            // Get the viewmodel from the DataContext
            CustomDialogViewModel viewmodel = DataContext as CustomDialogViewModel;

            // Call command from viewmodel
            if ((viewmodel != null) && (viewmodel.Rendered.CanExecute(null)))
            {
                viewmodel.Rendered.Execute(null);
            }
        }
Exemplo n.º 2
0
        // Custom dialog:
        public static void ExampleTwo(object parameter)
        {
            DialogData data = new DialogData()
            {
                WindowTitle       = "Example...",
                DialogWindowStyle = WindowStyle.SingleBorderWindow,
                WindowIconURI     = "pack://application:,,,/Resources/gear_icon2.ico",
                Topmost           = true,
            };

            CustomDialogViewModel customDialogViewModel = new CustomDialogViewModel(data);
            DialogUserControlView dialogUserControlView = new DialogUserControlView(customDialogViewModel, new CustomDialog(data));

            WindowMessageResult result = DialogService.OpenDialog(dialogUserControlView, parameter as Window);
        }
Exemplo n.º 3
0
        private void contentLoaded(object sender, RoutedEventArgs e)
        {
            // Gets the Window object reference encapsulating this control.
            window = Window.GetWindow(this);

            // Subscribes to the Rendered Event of the DialogBaseWindow that sets this control as its datacontext.
            window.ContentRendered += contentRendered;

            // Get the viewmodel from the DataContext
            CustomDialogViewModel viewmodel = DataContext as CustomDialogViewModel;

            // Call command from viewmodel
            if ((viewmodel != null) && (viewmodel.Loaded.CanExecute(window)))
            {
                viewmodel.Loaded.Execute(window);
            }
        }