Here is an example of a view model class with a command that handles an event from the UI:
public class SimpleViewModel
{
public SimpleViewModel()
{
TappedCommand = new EventCommand<Point>(OnTapped);
}
public IEventCommand TappedCommand { get; private set; }
private void OnTapped(Point point)
{
// You can mark event as handled by using the PreventBubbling property.
// This property value will not be reset by automatically.
// So you can set it once in the constructor or update it anywhere.
TappedCommand.PreventBubbling = point.X < 100;
}
}
Lets bind it to the Tapped event in XAML:
<Grid Mvvm:EventBinding.Tapped="{Binding TappedCommand}">
<!-- Your content -->
</Grid>