HELP - with X# syntax - Relay Command ...
Posted: Thu Jan 12, 2017 5:03 pm
Hi guys,
I need your help - PLEASE !
I am currently trying to add a RelayCommand class to my 'Stock' app for Cologne.
The C# class came from an article in C#Corner and I have the code working in one of my earlier apps. Now I want to translate it all to X#, and the central class is the 'RelayCommand' class. I am not using a MVVM framework doing things this way.
I have done some of the translating so here is my imperfect attempt (so far) :-
And here is the image of the C# code for comparison :-
And I suppose you guys want the text code too :-
====================================================================
public class RelayCommand implements ICommand
//----- from C# Corner -----
private execute as Action<object>
private canExecute as Func<object, Boolean>
//----- events -----
public event CanExecuteChanged as EventHandler
add ( CommandManager.RequerySuggested += value )
remove ( CommandManager.RequerySuggested -= value )
return
//--- constructor ---
constructor(execute as Action<object>, canExecute := null as Func<object, Boolean> )
self:execute := execute
self:canExecute := canExecute
return
//--- methods ---
public method CanExecute(parameter as object) as Boolean
return ( self:canExecute == null || self:canExecute(parameter) )
public method Execute(parameter as object) as void
self:execute(parameter)
return
end class
======================================================================
Any suggestions welcomed - TIA.
Regards,
Phil.
Wales, UK.
I need your help - PLEASE !
I am currently trying to add a RelayCommand class to my 'Stock' app for Cologne.
The C# class came from an article in C#Corner and I have the code working in one of my earlier apps. Now I want to translate it all to X#, and the central class is the 'RelayCommand' class. I am not using a MVVM framework doing things this way.
I have done some of the translating so here is my imperfect attempt (so far) :-
And here is the image of the C# code for comparison :-
And I suppose you guys want the text code too :-
====================================================================
public class RelayCommand implements ICommand
//----- from C# Corner -----
private execute as Action<object>
private canExecute as Func<object, Boolean>
//----- events -----
public event CanExecuteChanged as EventHandler
add ( CommandManager.RequerySuggested += value )
remove ( CommandManager.RequerySuggested -= value )
return
//--- constructor ---
constructor(execute as Action<object>, canExecute := null as Func<object, Boolean> )
self:execute := execute
self:canExecute := canExecute
return
//--- methods ---
public method CanExecute(parameter as object) as Boolean
return ( self:canExecute == null || self:canExecute(parameter) )
public method Execute(parameter as object) as void
self:execute(parameter)
return
end class
======================================================================
Any suggestions welcomed - TIA.
Regards,
Phil.
Wales, UK.