I'm using the Manipulation
events ( IsManipulationEnabled
, ManipulationDelta
, etc) to move and zoom an image. This works fine. I also want to use right-click to create a rectangle of selection to define a zone (drag and drop, the usual way, only with right-click) on the image. It works fine using the mouse on both touch (Surface) and non-touch (Win 7) devices. Though, when "right-clicking" on the Surface (therefore tap and hold with a finger), I see the typical little square appearing, but when I move my finger after that, it moves the image, instead of drawing the rectangle. It looks as if the Manipulation
events have priority over the "finger right click". What am I doing wrong ?
<Grid
Name="theGrid"
MouseMove="OnMouseMove"
MouseRightButtonUp="theGrid_MouseRightButtonUp"
MouseRightButtonDown="theGrid_MouseRightButtonDown"
Background="Black">
<Rectangle Name="RectangleContainingBackgroundImage"
IsManipulationEnabled="True"
RenderTransform="{Binding Path=ImageTransform}">
<Rectangle.Fill>
<ImageBrush x:Name="BackgroundImage" Stretch="Uniform"/>
</Rectangle.Fill>
</Rectangle>
At start :
ScreenTouchManager touchManager = new ScreenTouchManager(this.theGrid);
this.RectangleContainingBackgroundImage.ManipulationStarting += touchManager.Image_ManipulationStarting;
this.RectangleContainingBackgroundImage.ManipulationDelta += touchManager.Image_ManipulationDelta;
this.DataContext = touchManager;
In ScreenTouchManager :
public void Image_ManipulationStarting(object sender, ManipulationStartingEventArgs e)
{
// Ask for manipulations to be reported relative to the grid
e.ManipulationContainer = this.ManipContainer; // MC = constructor param
}
Thank you.
I did a research and may find a answer here: http://www.mobilemotion.eu/?p=1396&lang=en
The VisualState changes are triggered by dedicated mouse events: For example, the Pressed state is reached when the button's OnMouseLeftButtonDown event occurs. The finger touch-and-hold event is usually mapped to a click with the right mouse button (when tapping on the screen and not instantly releasing the finger, Windows interprets this as right-click operation) – the OnMouseLeftButtonDown event never fires, and the Pressed state is never reached!
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.