-
- jpattersonCSpeed
- Posts: 7
- Joined:
Cannot tap an image to trigger a click event when manipulation events are subscribed to
Hello again,
I have an image that manipulations can be performed on to zoom and pan it using ManipulationStarting, ManipulationInertiaStarting, ManipulationDelta, and ManipulationCompleted events that are managed by a ViewModule base class:
Inside of the code behind for a view that extends this class, we find an Image that needs to be manipulated and call to set up the touch manipulations.
I would also like to be able to tap the image to perform an action, and have the MouseDown event of the image subscribed to with a handler that is in the code behind of the view. Clicking on the image with a mouse causes the MouseDown event to trigger, but tapping on the image always causes the ManipulationEvents to trigger. Removing the ManipulationEvents allows the MouseDown event to be triggered when tapping the image. I've also seen buttons that have handlers subscribed to their MouseDown events work when tapped.
Is it expected that subscribing to manipulation events causes taps to not register as clicks? If it is, is there an easy way to mimic tapping behavior?
I have an image that manipulations can be performed on to zoom and pan it using ManipulationStarting, ManipulationInertiaStarting, ManipulationDelta, and ManipulationCompleted events that are managed by a ViewModule base class:
Code: Select all
public abstract class ManipulationViewModuleBase : ModuleViewBase
{
public ManipulationViewModuleBase(IEventAggregator ea) : base(ea)
{
}
protected void SubscribeManipulations(UIElement control)
{
control.IsManipulationEnabled = true;
control.ManipulationStarting += StartManipulation;
control.ManipulationInertiaStarting += StartingManipulation;
control.ManipulationDelta += ChangeManipulation;
control.ManipulationCompleted += CompleteManipulation;
}
protected void UnsubscribeManipulations(UIElement control)
{
control.ManipulationStarting -= StartManipulation;
control.ManipulationInertiaStarting -= StartingManipulation;
control.ManipulationDelta -= ChangeManipulation;
control.ManipulationCompleted -= CompleteManipulation;
control.IsManipulationEnabled = false;
}
protected void StartManipulation(object sender, ManipulationStartingEventArgs e)
{
// Acknowledge that the manipulation is starting and set some values
e.Handled = true;
}
protected void StartingManipulation(object sender, ManipulationInertiaStartingEventArgs e)
{
// Handle some manipulation start setup
e.Handled = true;
}
protected void ChangeManipulation(object sender, ManipulationDeltaEventArgs e)
{
// Handle deltas in the manipulation
e.Handled = true;
}
protected void CompleteManipulation(object sender, ManipulationCompletedEventArgs e)
{
// Handle manipulation complete
e.Handled = true;
}
}
Code: Select all
SubscribeManipulations(ImageControl)
I would also like to be able to tap the image to perform an action, and have the MouseDown event of the image subscribed to with a handler that is in the code behind of the view. Clicking on the image with a mouse causes the MouseDown event to trigger, but tapping on the image always causes the ManipulationEvents to trigger. Removing the ManipulationEvents allows the MouseDown event to be triggered when tapping the image. I've also seen buttons that have handlers subscribed to their MouseDown events work when tapped.
Is it expected that subscribing to manipulation events causes taps to not register as clicks? If it is, is there an easy way to mimic tapping behavior?
Re: Cannot tap an image to trigger a click event when manipulation events are subscribed to
Yes, right now we are WPF compliant and manipulations absorb normal events. We have plans to migrate to the UWP approach where manipulations and clicks follow different routes.Is it expected that subscribing to manipulation events causes taps to not register as clicks? If it is, is there an easy way to mimic tapping behavior?
We are also working in implementing high-level events like Tap so if this is not very critical for you I would wait. If you need a solution right now, I would implement the 'Tap' event by checking inside CompleteManipulation if the touch position only moved "a bit" and time ellapsed since StartManipulation is small. Please, let me know if you need more help about this.
-
- jpattersonCSpeed
- Posts: 7
- Joined:
Re: Cannot tap an image to trigger a click event when manipulation events are subscribed to
Alright thanks. I am interpreting taps based on manipulation events that are relatively short where the user doesn't move too much.
Who is online
Users browsing this forum: No registered users and 1 guest