コード例 #1
0
        public async void Show(object dialogContent, IOKCancelViewModel viewModel)
        {
            var contentDialog = new Windows.UI.Xaml.Controls.ContentDialog
            {
                Content           = dialogContent,
                PrimaryButtonText = "Ok",
                CloseButtonText   = "Cancel",
                MinWidth          = 1000,
            };

            if (viewModel != null)
            {
                Console.WriteLine("hooking");
                contentDialog.DataContext = viewModel;
                contentDialog.Closing    += (sender, args) =>
                {
                    Console.WriteLine("Closing " + args.Result);

                    if (args.Result == ContentDialogResult.Primary)
                    {
                        viewModel.OK(args);
                    }
                };
            }
            var res = await contentDialog.ShowAsync(ContentDialogPlacement.Popup);
        }
コード例 #2
0
        public OkCancelDialog(object content, IOKCancelViewModel viewModel)
        {
            InitializeComponent();
            CancelCommand = new RelayCommand(() => Close());
            GotFocus     += OkCancelWindowGotFocus;


            DataContext   = viewModel;
            WindowMessage = content;
        }
コード例 #3
0
        // attempt to get a simpler interface
        public OkCancelWindow(object content, IOKCancelViewModel viewModel)
        {
            Console.WriteLine("okcancel ctor-before");
            // copied from default ctor due to https://github.com/nventive/Uno/issues/61
            InitializeComponent();
            CancelCommand = new HseDelegateCommand(o => Close());
            GotFocus     += OkCancelWindowGotFocus;
            Console.WriteLine("okcancel ctor");

            OkCommand = new HseDelegateCommand(_ =>
            {
                Console.WriteLine("ok command");
                if (viewModel.OK(this))
                {
                    Close();
                    viewModel.Dispose();
                }
            },
                                               viewModel.OkCanExecute);
            CancelCommand = new HseDelegateCommand(_ =>
            {
                if (viewModel.Cancel())
                {
                    Close();
                    viewModel.Dispose();
                }
            },
                                                   viewModel.CancelCanExecute);
            viewModel.OkCommand     = OkCommand;
            viewModel.CancelCommand = CancelCommand;
            WindowMessage           = content;
            SetBinding(OkTextProperty, new Binding {
                Path = new PropertyPath("OkText")
            });
            SetBinding(CancelTextProperty, new Binding {
                Path = new PropertyPath("CancelText")
            });
            DataContext    = viewModel;
            viewModel.View = this;
        }