Ejemplo n.º 1
0
        public void WhenOpenDialogsAreOpenIsExist()
        {
            object id = Guid.NewGuid();

            _dialogHost.Identifier = id;
            bool isExist = false;

            _ = _dialogHost.ShowDialog("Content", new DialogOpenedEventHandler((sender, arg) =>
            {
                isExist = DialogHost.IsDialogOpen(id);
            }));
            Assert.True(isExist);
            DialogHost.Close(id);
            Assert.False(DialogHost.IsDialogOpen(id));
        }
Ejemplo n.º 2
0
 private static async void DisplayDialog(string msg)
 {
     if (!DialogHost.IsDialogOpen("MainDialogHost"))
     {
         SystemSounds.Exclamation.Play();
         ErrorDialog error = new();
         error.Message = msg;
         _             = await DialogHost.Show(error, "MainDialogHost");
     }
     else
     {
         DialogHost.Close("MainDialogHost");
         SystemSounds.Exclamation.Play();
         ErrorDialog error = new();
         error.Message = msg;
         _             = await DialogHost.Show(error, "MainDialogHost");
     }
 }
Ejemplo n.º 3
0
        public async Task WhenOnlySingleDialogHostIdentifierIsNullItShowsDialog()
        {
            DialogHost dialogHost2 = new();

            dialogHost2.ApplyDefaultStyle();
            dialogHost2.Identifier = Guid.NewGuid();

            try
            {
                dialogHost2.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
                Task showTask = DialogHost.Show("Content");
                Assert.True(DialogHost.IsDialogOpen(null));
                Assert.False(DialogHost.IsDialogOpen(dialogHost2.Identifier));
                DialogHost.Close(null);
                await showTask;
            }
            finally
            {
                dialogHost2.RaiseEvent(new RoutedEventArgs(FrameworkElement.UnloadedEvent));
            }
        }
Ejemplo n.º 4
0
    public static async Task <object> ShowAsync(object model, string dialogName)
    {
        var view           = Instance.ViewManager.CreateAndBindViewForModelIfNecessary(model);
        var session        = DialogHost.GetDialogSession(dialogName);
        var sessionContext = (session?.Content as FrameworkElement)?.DataContext;

        if (model.Equals(sessionContext))
        {
            return(null);
        }

        if (DialogHost.IsDialogOpen(dialogName))
        {
            DialogHost.Close(dialogName);
        }

        (model as IScreenState)?.Activate();
        var result = await DialogHost.Show(view, dialogName).ConfigureAwait(true);

        (model as IScreenState)?.Deactivate();
        return(result);
    }