I'm using an ScrollViewer in the MVVM enviroment to navigate around an map of europe. But when I use the ScrollViewer the deltaScale for the manipulationDeltaEventArgs.Pinchmanipulation doesn't work. The DeltaScale stays at one, no matter what. I tried to take a look at the Current and Original of the Pinchmanipulation and they are the same. So can anyone help me with making it possible to zoom while having an scrollViewer?
The manipulationDelta is:
public void Zoom(ManipulationDeltaEventArgs e)
{
if (e.PinchManipulation == null)
{
return;
}
}
I don't think scrollviewer supports zooming in Windows Phone 8. Only Windows Store apps can do this right now.
Related
I am working on a windows 10 universal App.The basic structure of my page is like
<Grid>
<ScrollViewer ViewChanged="MyScrollViewer_ViewChanged" VerticalScrollBarVisibility="Auto" VerticalScrollMode="Enabled" HorizontalScrollBarVisibility="Disabled" HorizontalScrollMode="Disabled" IsVerticalRailEnabled="True" IsVerticalScrollChainingEnabled="True">
<Pivot>
<PivotItem/>
<PivotItem/>
<PivotItem/>
<PivotItem/>
</Pivot>
</ScrollViewer>
</Grid>
And in my code behind i wrote the event to handle Scroll changed like this
private void MyScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
{
//My business logic goes here
}
For each pivot item, there is contents to scroll.
When i run the App what happens is
when i tried to scroll from the scroll bar on the right side,my MyScrollViewer_ViewChanged event getting fired but when i tried to scroll with the mouse wheel,the event not getting fired and i was not able to continue.
Please help to find out the issue.
Thanks
The pivot inside your scrollviewer is intercepting your touch and mouse wheel interactions, that is why you are not receiving anything with your mouse wheel.
Placing a pivot within a scrollviewer is really really weird. What behavior are you trying to achieve ? If you want to scroll vertically in each of the pivot items you should place a scrollviewer in each of your PivotItems, not around your pivot.
I had the same problem i fixed it like this but i hope we find a better way cause it buggy.
private void PivotItem_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
{
if (e.GetCurrentPoint(scrollViewer).Properties.MouseWheelDelta == (-120))
{
// On Mouse Wheel scroll Backward
scrollViewer.ChangeView(null, scrollViewer.VerticalOffset + Window.Current.CoreWindow.Bounds.Height / 10, null, false);
}
if (e.GetCurrentPoint(scrollViewer).Properties.MouseWheelDelta == (120))
{
// On Mouse Wheel scroll Forward
scrollViewer.ChangeView(null,scrollViewer.VerticalOffset - Window.Current.CoreWindow.Bounds.Height / 10, null, false);
}
}
i need to display some images on maps in WP8, that need to stay at their exact position and cover a specific area (these are pictures of buildings that are displayed on a Road Map) but
as far as i know there is no way to make that happen when zooming is allowed.
I can get rid of the Double Tap zooming by simply resetting the zoom level, but i have a problem with pinch zooming because this creates a very ugly jumpy effect.
private void MapTwo_ZoomLevelChanged(object sender, Microsoft.Phone.Maps.Controls.MapZoomLevelChangedEventArgs e)
{
MyMap.ZoomLevel=16;
}
I don't want to disable all user interaction though.
Any advice?
I'm attempting to create something of a software zoom for an image in my Winforms application. I noticed an answer to a similar issue stating that it could be achieved with the mousewheel by using
private void image_MouseWheel(object sender, MouseWheelEventArgs e)
{
var st = (ScaleTransform)image.RenderTransform;
double zoom = e.Delta > 0 ? .2 : -.2;
st.ScaleX += zoom;
st.ScaleY += zoom;
}
That solution is exactly what I need, but it appears to be part of System.Windows.Media, which doesn't seem to be part of the Winforms architecture.
Does anyone know of a similar option for Winforms that would end up resembling this functionality? My google searches haven't turned up much :(
Thanks!
You might want to look into Graphics.ScaleTransform. The idea of arbitrary transformations as part of the rendering process isn't as all-pervasive in Windows Forms, but you could transform one image to another image via Graphics, I believe.
How would I draw something on a Canvas in C# for Windows Phone?
Okay, let me be a little more clear.
Say the user taps his finger down at 386,43 on the canvas. (the canvas is 768 by 480)
I would like my application to be able to respond by placing a red dot at 386,43 on the canvas.
I have no prior experience with Canvas whatsoever.
If this is too complex to be answered in one question (which it probably is), please give me links to other websites with Canvas and Drawing articles.
There are various ways of doing this. Depending on the nature of the red dot, you could make it a UserControl. For a basic circle, you can simply handle your canvas' ManipulationStarted event.
private void myCanvas_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
{
Ellipse el = new Ellipse();
el.Width = 10;
el.Height = 10;
el.Fill = new SolidColorBrush(Colors.Red);
Canvas.SetLeft(el, e.ManipulationOrigin.X);
Canvas.SetTop(el, e.ManipulationOrigin.Y);
myCanvas.Children.Add(el);
}
I think you need to approach the problem differently. (I'm not including code on purpose, because of that).
Forms and controls in an Windows applications (including Phone) can be refreshed for several reasons, at any time. If you draw on a canvas in response to a touch action, you have an updated canvas until the next refresh. If a refresh occurs the canvas repaints itself, you end up with a blank canvas.
I have no idea what your end goal is, but you likely want to either keep track of what the user has done and store that state somewhere and show it in a canvas on the repaint of the canvas. This could be done with storing all the actions and "replaying" them on the canvas, or simply storing the view of the canvas as a bitmap and reload the canvas with that bitmap when refreshed. But, in the later case I think using a canvas isn't the right solution.
I am using the .net 4 beta 2 touch libraries, and Im trying to implement a zooming feature in my WPF application.
I can get the zooming working just fine, but what I want is to zoom in on the center of the pinch gesture, and I cannot see anything in the API's about how to accomplish this.
Is there some methods or properties that expose the 2 contacts being using in the pinch gesture so that I can get the center of them?
EDIT:
I just investigated using the GetIntermediateTouchPoints method of TouchEventArgs which did not seem to give me what I want.
Thanks a lot
Mark
Assuming you are using the new TouchXxxxEvent routed events, they all take TouchEventArgs, which has TouchDevice property. If you call its GetTouchPoint() method, you can get the TouchPoint that represents the point of touch.
More details and sample code from Jaime Rodriguez.
Turns out that the properties I was after was right in front of me all along.
the Manipulation2DDeltaEventArgs class has OriginX and OriginX properties that specific the center point of the pinch gesture, so Im just using that and its all good :)
This answer is for .Net 4 release version.
In the case of using ManipulationDelta event the ManipulationDeltaEventArgs.ManipulationOrigin contains center point of the pinch gesture. The coordinates are relative to the ManipulationDeltaEventArgs.ManipulationContainer, which could be set in the handler of ManipulationStarting event.
Example code:
private void object_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
...
// If this was a multitouch gesture
// (like pinch/zoom - indicated by e.DeltaManipulation.Scale)
// the following line will get us point between fingers.
Point position = e.ManipulationOrigin;
...
}