Horje
How to use multiple Commands for one ViewModel Code Example
How to use multiple Commands for one ViewModel
public class RelayCommand : ICommand
{
    private readonly Predicate<object> _canExecute;
    private readonly Action<object> _execute;

    public RelayCommand(Predicate<object> canExecute, Action<object> execute)
    {
        this._canExecute = canExecute;
        this._execute = execute;
    }

    public event EventHandler CanExecuteChanged
    {
        add => CommandManager.RequerySuggested += value;
        remove => CommandManager.RequerySuggested -= value;
    }

    public bool CanExecute(object parameter)
    {
        return _canExecute(parameter);
    }

    public void Execute(object parameter)
    {
        _execute(parameter);
    }
}
How to use multiple Commands for one ViewModel
public ICommand Command1 { get { return new RelayCommand(e => true, this.MethodForCommand1); } }
public ICommand Command2{ get { return new RelayCommand(e => true, this.MethodForCommand2); } }
private void MethodForCommand1(object obj){ //Type your code for Command1 }
private void MethodForCommand2(object obj){ //Type your code for Command2 }
How to use multiple Commands for one ViewModel
    <Button Content="Button 1" Command="{Binding Command1}"/>
    <Button Content="Button 2" Command="{Binding Command2}"/>




Csharp

Related
nethereum check gas price Code Example nethereum check gas price Code Example
Browse C# Code Examples Browse C# Code Examples
random number between 1 and 100 c# Code Example random number between 1 and 100 c# Code Example
in clause db2 c# Code Example in clause db2 c# Code Example
.net directorysearcher get manager accountname Code Example .net directorysearcher get manager accountname Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9