mirror of
https://github.com/holgerb83/ModernWpfPlayground.git
synced 2025-04-19 23:03:49 +02:00
removed RelayCommand.cs
This commit is contained in:
parent
bd7f504a56
commit
97ed0d9be0
@ -1,35 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Windows.Input;
|
|
||||||
|
|
||||||
namespace ModernWpfPlayground.MvvmStuff
|
|
||||||
{
|
|
||||||
public class RelayCommand : ICommand
|
|
||||||
{
|
|
||||||
private readonly Predicate<object>? _canExecute;
|
|
||||||
private readonly Action<object> _execute;
|
|
||||||
|
|
||||||
public RelayCommand(Action<object> execute)
|
|
||||||
{
|
|
||||||
_execute = execute;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
|
|
||||||
{
|
|
||||||
_canExecute = canExecute;
|
|
||||||
_execute = execute;
|
|
||||||
}
|
|
||||||
|
|
||||||
public event EventHandler CanExecuteChanged
|
|
||||||
{
|
|
||||||
add => CommandManager.RequerySuggested += value;
|
|
||||||
remove => CommandManager.RequerySuggested -= value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanExecute(object parameter) => _canExecute?.Invoke(parameter) ?? true;
|
|
||||||
|
|
||||||
public void Execute(object parameter)
|
|
||||||
{
|
|
||||||
_execute(parameter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,6 +8,7 @@ using System.Windows;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using ModernWpfPlayground.MvvmStuff;
|
using ModernWpfPlayground.MvvmStuff;
|
||||||
|
using Prism.Commands;
|
||||||
|
|
||||||
namespace ModernWpfPlayground
|
namespace ModernWpfPlayground
|
||||||
{
|
{
|
||||||
@ -43,11 +44,11 @@ namespace ModernWpfPlayground
|
|||||||
|
|
||||||
public WindowViewModel()
|
public WindowViewModel()
|
||||||
{
|
{
|
||||||
ShowDialogCommand = new RelayCommand(async x => await ShowDialogAsync().ConfigureAwait(false));
|
ShowDialogCommand = new DelegateCommand(async () => await ShowDialogAsync().ConfigureAwait(false));
|
||||||
CloseCommand = new RelayCommand(x => Application.Current.Shutdown());
|
CloseCommand = new DelegateCommand(() => Application.Current.Shutdown());
|
||||||
OpenViewModelCommand = new RelayCommand(x => LoadViewModel());
|
OpenViewModelCommand = new DelegateCommand(LoadViewModel);
|
||||||
SaveViewModelCommand = new RelayCommand(x => SaveViewModel());
|
SaveViewModelCommand = new DelegateCommand(SaveViewModel);
|
||||||
ResetViewModelCommand = new RelayCommand(x =>
|
ResetViewModelCommand = new DelegateCommand(() =>
|
||||||
{
|
{
|
||||||
ResetViewModel();
|
ResetViewModel();
|
||||||
Path = null;
|
Path = null;
|
||||||
@ -91,7 +92,7 @@ namespace ModernWpfPlayground
|
|||||||
set => SetProperty(value);
|
set => SetProperty(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand ShowDialogCommand { get; }
|
public ICommand ShowDialogCommand { get; }
|
||||||
|
|
||||||
public string WelcomeMessage
|
public string WelcomeMessage
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user