Skip to content

Instantly share code, notes, and snippets.

@julesx
Created April 19, 2017 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julesx/c0cc2846a99a6537f6ebb8475a5e8b23 to your computer and use it in GitHub Desktop.
Save julesx/c0cc2846a99a6537f6ebb8475a5e8b23 to your computer and use it in GitHub Desktop.
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