Reputation: 1060
I've recently rebuilt an app for Windows Phone 8, but with the new Silverlight Toolkit, GestureListener is no longer present, warning: "GestureListener is not supported in a Silverlight project". I really want to implement a gesture navigation system into my app whereby the page can be swiped left or right to navigate to one of two other pages, but only after a certain "drag threshold" - this was nicely shown in WP7 here (the behaviour for deleting items I would like to apply to my MainPage) - but without the old controls I can't see a clear way to do this, after trying relentlessly. Now there are apparently only three Manipulation Events we can use, which has complicated a process that was so much easier before. I'm trying to make the whole page (ie. the first ContentPanel) moveable along the horizontal, but can't even achieve this now. Please could somebody help, in any way?
Upvotes: 1
Views: 710
Reputation: 46
using Microsoft.Phone.Controls;
namespace PhoneApp2
{
public partial class MainPage : PhoneApplicationPage
{
double _x = 0;
double _y = 0;
double _x2 = 0;
double _y2 = 0;
public MainPage()
{
InitializeComponent();
}
private void PhoneApplicationPage_ManipulationStarted_1(object sender, System.Windows.Input.ManipulationStartedEventArgs e)
{
_x = e.ManipulationOrigin.X;
_y = e.ManipulationOrigin.Y;
}
private void PhoneApplicationPage_ManipulationCompleted_1(object sender, System.Windows.Input.ManipulationCompletedEventArgs e)
{
_x2 = e.ManipulationOrigin.X;
_y2 = e.ManipulationOrigin.Y;
string _xx = string.Format(" x:{0} y:{1} x2:{2} y2:{3}", _x, _y, _x2, _y2);
if (_y > _y2 && _y - _y2 > 100)
{
lbl1.Text = "up" + _xx;
}
else if (_x > _x2 && _x - _x2 > 100)
{
lbl1.Text = "left" + _xx;
}
else if (_y < _y2 && _y2 - _y > 100)
{
lbl1.Text = "down" + _xx;
}
else if (_x < _x2 && _x2 - _x > 100)
{
lbl1.Text = "right" + _xx;
}
}
}
}
Upvotes: 3