The steps above generate the following XAML, which you could of course write yourself in Visual Studio if you wanted.
<m:Map x:Name="map">
<Custom:Interaction.Triggers>
<Controls:MapTapTrigger>
<ic:GoToStateAction StateName="MapOnlyState"/>
</Controls:MapTapTrigger>
</Custom:Interaction.Triggers>
</m:Map>
Â
To use this trigger simply paste the class into your project and compile. Blend will find it automatically when the Select Object window opens.
public class MapTapTrigger : TriggerBase<Map>
{
private bool _isTapOnly = true;
/// <summary>
/// Attach from the appropriate events.
/// </summary>
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.MapZoom += MapZoom;
AssociatedObject.MapPan += MapPan;
AssociatedObject.MouseLeftButtonUp += MouseLeftButtonUp;
}
private void MapZoom(object sender, MapZoomEventArgs e)
{
_isTapOnly = false;
}
private void MapPan(object sender, MapDragEventArgs e)
{
_isTapOnly = false;
}
private void MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (_isTapOnly)
{
InvokeActions(e);
}
_isTapOnly = true;
}
/// <summary>
/// Detach from the appropriate events.
/// </summary>
protected override void OnDetaching()
{
base.OnDetaching();
AssociatedObject.MapZoom -= MapZoom;
AssociatedObject.MapPan -= MapPan;
AssociatedObject.MouseLeftButtonUp -= MouseLeftButtonUp;
}
}
Leave a Comment