Exemplo n.º 1
0
        private async Task <ContentDialogResult> ShowContentDialog(ContentDialog contentDialog)
        {
            // First ContentDialog is shown as InPlace.
            if (ContentDialogBorder.Child == null)
            {
                ContentDialogBorder.Child = contentDialog;
            }

            var viewModel = DataContext as MainViewModel;

            hotKey?.Dispose();
            viewModel.IsShowingContentDialog = true;
            var currentElement = FocusManager.GetFocusedElement(this);

            contentDialog.Focus();
            var result = await contentDialog.ShowAsync(ContentDialogPlacement.InPlace);

            TryRegisterHotKey(viewModel.Settings.HotKey, out hotKey);
            viewModel.IsShowingContentDialog = false;
            currentElement?.Focus();

            if (ContentDialogBorder.Child == contentDialog)
            {
                ContentDialogBorder.Child = null;
            }

            return(result);
        }
Exemplo n.º 2
0
 public bool Activate()
 {
     return(_window.Focus(FocusState.Programmatic));
 }