Help with MVVM RelayCommand translation from C# to X#
Posted: Mon Jun 19, 2017 10:32 pm
I've been trying to translate a sample MVVM "RelayCommand" I've found online. Here is the URL of a great example I'm using as a guide, https://msdn.microsoft.com/en-us/magazine/dd419663.aspx.
I am trying to translate the following:
readonly Action<object> _execute;
readonly Predicate<object> _canExecute;
public RelayCommand(Action<object> execute) : this(execute, null) { }
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");
_execute = execute; _canExecute = canExecute;
}
Here is my current attempt, which I'm not sure if I'm on the right path:
private _execute as Action<object>
private _canExecute as Predicate<object>
CONSTRUCTOR()
RETURN
CONSTRUCTOR (execute as Action<object>) : self(execute, null)
return
CONSTRUCTOR (execute as Action<object>, canExecute as Predicate<object>)
return
This doesn't compile. Any suggestion?
Thanks
Boonnam
I am trying to translate the following:
readonly Action<object> _execute;
readonly Predicate<object> _canExecute;
public RelayCommand(Action<object> execute) : this(execute, null) { }
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");
_execute = execute; _canExecute = canExecute;
}
Here is my current attempt, which I'm not sure if I'm on the right path:
private _execute as Action<object>
private _canExecute as Predicate<object>
CONSTRUCTOR()
RETURN
CONSTRUCTOR (execute as Action<object>) : self(execute, null)
return
CONSTRUCTOR (execute as Action<object>, canExecute as Predicate<object>)
return
This doesn't compile. Any suggestion?
Thanks
Boonnam