示例#1
0
        public async Task <bool?> ShowDialog(object dialogViewModel)
        {
            var window = Application.Current.MainWindow;

            if (window == null)
            {
                return(null);
            }
            if (!WindowChromeBehavior.GetIsEnable(window))
            {
                return(null);
            }

            WindowChromeBehavior.SetDialogContent(window, dialogViewModel);

            var dialogContentControl = window.FindChildrenFromTemplate <ContentControl>("PART_DialogContainer");

            if (dialogContentControl == null)
            {
                return(null);
            }
            await Task.Delay(100);

            var dialog = dialogContentControl.FindChildren <MetroDialog>().FirstOrDefault();

            if (dialog == null)
            {
                return(false);
            }
            await Task.Run(() =>
            {
                while (dialog.IsVisible)
                {
                }
            });

            return(dialog.DialogResult);
        }
示例#2
0
 private void CloseButton_Click(object sender, RoutedEventArgs e)
 {
     WindowChromeBehavior.SetDialogContent(Application.Current.MainWindow, null);
     this.DialogResult = false;
 }