diff --git a/src/Consolonia.Core/Controls/FileSavePicker.axaml.cs b/src/Consolonia.Core/Controls/FileSavePicker.axaml.cs index 21d80aea..f12f76a6 100644 --- a/src/Consolonia.Core/Controls/FileSavePicker.axaml.cs +++ b/src/Consolonia.Core/Controls/FileSavePicker.axaml.cs @@ -58,8 +58,9 @@ private void OnDoubleTapped(object sender, TappedEventArgs e) private async void OnOK(object sender, RoutedEventArgs e) { - var lifetime = (IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime; + var lifetime = Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime; ArgumentNullException.ThrowIfNull(lifetime); + ArgumentNullException.ThrowIfNull(lifetime.MainWindow); var savePath = ViewModel.SavePath; if (!Path.IsPathFullyQualified(ViewModel.SavePath)) diff --git a/src/Consolonia.Core/Controls/FileSavePickerViewModel.cs b/src/Consolonia.Core/Controls/FileSavePickerViewModel.cs index 20ad6636..b8b42e9d 100644 --- a/src/Consolonia.Core/Controls/FileSavePickerViewModel.cs +++ b/src/Consolonia.Core/Controls/FileSavePickerViewModel.cs @@ -6,7 +6,7 @@ namespace Consolonia.Core.Controls { public partial class FileSavePickerViewModel : PickerViewModelBase { - [ObservableProperty] private string _savePath; + [ObservableProperty] private string _savePath=string.Empty; [ObservableProperty] [NotifyPropertyChangedFor(nameof(SelectedFile))] private IStorageItem _selectedItem; @@ -15,14 +15,14 @@ public FileSavePickerViewModel(FilePickerSaveOptions options) : base(options) { ArgumentNullException.ThrowIfNull(options, nameof(options)); - this.PropertyChanged += FileSavePickerViewModel_PropertyChanged; ; + this.PropertyChanged += FileSavePickerViewModel_PropertyChanged; } private void FileSavePickerViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == nameof(SelectedFile)) { - SavePath = SelectedFile?.Path.LocalPath; + SavePath = SelectedFile.Path.LocalPath; } } @@ -30,19 +30,6 @@ private void FileSavePickerViewModel_PropertyChanged(object sender, System.Compo protected override bool FilterItem(IStorageItem item) { - //if (item is IStorageFolder) return true; - //if (item is IStorageFile file) - //{ - // // ReSharper disable ConstantConditionalAccessQualifier - // if (SelectedFileType == null) - // return true; - - // foreach (string pattern in SelectedFileType.Patterns) - // if (file.Path.LocalPath.EndsWith(pattern.TrimStart('*'), StringComparison.OrdinalIgnoreCase)) - // return true; - // return false; - //} - return true; } }