Created
April 19, 2017 14:26
-
-
Save julesx/c0cc2846a99a6537f6ebb8475a5e8b23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CommandViewCell : ViewCell | |
{ | |
/// <summary> | |
/// The bindable property implementation | |
/// </summary> | |
public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create("CommandParameter", typeof(object), typeof(CommandViewCell)); | |
/// <summary> | |
/// The command parameter | |
/// </summary> | |
public object CommandParameter | |
{ | |
get | |
{ | |
return this.GetValue(CommandParameterProperty); | |
} | |
set | |
{ | |
this.SetValue(CommandParameterProperty, value); | |
} | |
} | |
/// <summary> | |
/// The bindable property implementation | |
/// </summary> | |
public static readonly BindableProperty CommandProperty = BindableProperty.Create("Command", typeof(Command), typeof(CommandViewCell)); | |
/// <summary> | |
/// The command which gets executed on tapping the cell | |
/// </summary> | |
public Command Command | |
{ | |
get | |
{ | |
return (Command)this.GetValue(CommandProperty); | |
} | |
set | |
{ | |
this.SetValue(CommandProperty, value); | |
} | |
} | |
/// <summary> | |
/// Override tapped event | |
/// </summary> | |
protected override void OnTapped() | |
{ | |
base.OnTapped(); | |
this.Command?.Execute(this.CommandParameter ?? this); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment