Exemplo n.º 1
0
        private async void OpenCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFileDialog    dialog;
            DocumentViewModel vm;

            dialog        = new OpenFileDialog();
            dialog.Filter = "xml files|*.xml|All files|*.*";
            if (!dialog.ShowDialog(this) ?? false)
            {
                return;
            }

            try
            {
                vm = new DocumentViewModel(logger);
                await vm.LoadAsync(dialog.FileName);

                await documentViewModel.AddAsync(null, vm);

                documentViewModel.SelectedItem = vm;
            }
            catch
            {
                documentViewModel.ErrorMessage = "Failed to load document";
            }
        }