I have a list of controls that I show through the WrapPanel, and it is horizontally oriented.
I applied the Click and Drag scrolling method to make the user scroll with the mouse by clicking and dragging.
Same:
<Canvas x:Name="ParentCanvas" PreviewMouseDown="Canvas_MouseDown" MouseMove="Canvas_MouseMove"> <WrapPanel> <WrapPanel.RenderTransform> <TranslateTransform /> </WrapPanel.RenderTransform> </WrapPanel> </Canvas>
Then in the code behind:
private Point _mousePosition; private Point _lastMousePosition; private void Canvas_MouseDown(object sender, MouseButtonEventArgs e) { _lastMousePosition = e.GetPosition(ParentCanvas); e.Handled = true; } private void Canvas_MouseMove(object sender, MouseEventArgs e) { _mousePosition = e.GetPosition(ParentCanvas); var delta = _mousePosition - _lastMousePosition; if(e.LeftButton == MouseButtonState.Pressed && delta.X != 0) { var transform = ((TranslateTransform)_wrapPanel.RenderTransform).Clone(); transform.X += delta.X; _wrapPanel.RenderTransform = transform; _lastMousePosition = _mousePosition; } }
It all works great.
But I want to make it so that when users click on the drag and drop, the elements in the WrapPanel dont respond (i.e. the user only views), but when the user clicks (as in a full click), then they respond to the click.
As the iphone works, when you click and drag directly into the application, it does not open the application, but scrolls the screen, but when you click the application, it starts ...
Hope this makes sense.
Cheers, Mark
source share