Skip to content

Instantly share code, notes, and snippets.

@kosorin
Created January 18, 2019 21:45
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 kosorin/838fd229f1b5659ecf762304cefcdd90 to your computer and use it in GitHub Desktop.
Save kosorin/838fd229f1b5659ecf762304cefcdd90 to your computer and use it in GitHub Desktop.
UWP behavior
public class ItemClickAction : DependencyObject, IAction
{
public ICommand Command
{
get { return (ICommand)GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
}
public static readonly DependencyProperty CommandProperty =
DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(ItemClickAction), new PropertyMetadata(null));
public object Execute(object sender, object parameter)
{
var clickedItem = (parameter as ItemClickEventArgs)?.ClickedItem;
if (clickedItem != null)
{
Command?.Execute(clickedItem);
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment