diff --git a/src/ClassLibrary1/Class1.cs b/src/ClassLibrary1/Class1.cs deleted file mode 100644 index 9996d38..0000000 --- a/src/ClassLibrary1/Class1.cs +++ /dev/null @@ -1,9 +0,0 @@ -using MVVMFluent; - -namespace ClassLibrary1 -{ - public class Class1 : ViewModelBase - { - - } -} diff --git a/src/ClassLibrary1/ClassLibrary1.csproj b/src/ClassLibrary1/ClassLibrary1.csproj deleted file mode 100644 index afdfc9a..0000000 --- a/src/ClassLibrary1/ClassLibrary1.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - net6.0 - enable - enable - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - diff --git a/src/MVVMFluent.NugetDemo/MVVMFluent.NugetDemo.csproj b/src/MVVMFluent.NugetDemo/MVVMFluent.NugetDemo.csproj index ccdc79c..93490b5 100644 --- a/src/MVVMFluent.NugetDemo/MVVMFluent.NugetDemo.csproj +++ b/src/MVVMFluent.NugetDemo/MVVMFluent.NugetDemo.csproj @@ -10,11 +10,7 @@ - - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/MVVMFluent.NugetDemo/MainViewModel.cs b/src/MVVMFluent.NugetDemo/MainViewModel.cs index b0b3726..edfaa73 100644 --- a/src/MVVMFluent.NugetDemo/MainViewModel.cs +++ b/src/MVVMFluent.NugetDemo/MainViewModel.cs @@ -5,12 +5,17 @@ namespace MVVMFluent.NugetDemo; internal class MainViewModel : ValidationViewModelBase { + public MainViewModel() + { + Input = "Hello World"; + } + public bool Enable { get => Get(true); set => Set(value); } public string? Input { get => Get(); - set => When(value).Required().Notify(OkCommand, AsyncCommand).Set(); + set => When(value).Required().Notify(AsyncCommand, OkCommand).Set(); } public Command OkCommand => Do(() => ShowDialog(Input)).IfValid(nameof(Input)); @@ -26,17 +31,20 @@ private bool CanExecute() private void HandleException(Exception exception) { - MessageBox.Show(exception.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); + if (exception is TaskCanceledException) + MessageBox.Show(exception.Message, "Information", MessageBoxButton.OK, MessageBoxImage.Information); + else + MessageBox.Show(exception.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } - private async Task ShowDialogAsync() + private async Task ShowDialogAsync(CancellationToken cancellationToken) { for (var i = 1; i <= 100; i++) { - if (AsyncCommand.IsCancellationRequested) - return; + if (cancellationToken.IsCancellationRequested) + throw new TaskCanceledException(); - await Task.Delay(50); + await Task.Delay(50, cancellationToken); AsyncCommand.ReportProgress(i + 1, 100); if (AsyncCommand.Progress == 50 && ThrowException) diff --git a/src/MVVMFluent.NugetDemo/MainWindow.xaml b/src/MVVMFluent.NugetDemo/MainWindow.xaml index 6b345f7..4cbee14 100644 --- a/src/MVVMFluent.NugetDemo/MainWindow.xaml +++ b/src/MVVMFluent.NugetDemo/MainWindow.xaml @@ -16,13 +16,13 @@