I am looking at the code from here
/// <summary>
/// Returns the command that, when invoked, attempts
/// to remove this workspace from the user interface.
/// </summary>
public ICommand CloseCommand
{
get
{
if (_closeCommand == null)
_closeCommand = new RelayCommand(param => this.OnRequestClose());
return _closeCommand;
}
}
what does param
in param => this.OnRequestClose()
refer to?
RelayCommand
is presumably a delegate-type that accepts a single parameter, or a type that itself takes such a delegate-type in the constructor. You are declaring an anonymous method, saying simply "when invoked, we'll take the incoming value (but then not use it), and call OnRequestClose
. You could also have (maybe clearer):
_closeCommand = new RelayCommand(delegate { this.OnRequestClose(); });
It is probably clearer in other uses where it is used, for example:
var ordered = qry.OrderBy(item => item.SomeValue);
where the lambda is "given an item
, obtain the item
's SomeValue
". In your case the lambda is "given param
, ignore param
and call OnRequestClose()
"
param => this.OnRequestClose() is lambda
Func<sometype_that_param_is,sometype_that_OnRequestClose_Is>
or Action
I'm not sure which
So it's just an expression for a func that is called by something, that will pass an argument which will be 'param' an then not used
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With