mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-05 02:26:29 +01:00
35 lines
970 B
C#
35 lines
970 B
C#
using System.Windows.Input;
|
|
using Xamarin.Forms;
|
|
|
|
namespace TINK.View
|
|
{
|
|
public static class ListViewAttachedBehavior
|
|
{
|
|
public static readonly BindableProperty CommandProperty =
|
|
BindableProperty.CreateAttached(
|
|
"Command",
|
|
typeof(ICommand),
|
|
typeof(ListViewAttachedBehavior),
|
|
null,
|
|
propertyChanged: OnCommandChanged);
|
|
|
|
static void OnCommandChanged(BindableObject view, object oldValue, object newValue)
|
|
{
|
|
var entry = view as ListView;
|
|
if (entry == null)
|
|
return;
|
|
|
|
entry.ItemTapped += (sender, e) =>
|
|
{
|
|
var command = (newValue as ICommand);
|
|
if (command == null)
|
|
return;
|
|
|
|
if (command.CanExecute(e.Item))
|
|
{
|
|
command.Execute(e.Item);
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|