I have a Windows 10 UWP app that is targeted for Windows 10 Mobile but also, I am testing on Microsoft Surface and with my mouse. I simply cannot get the Manipulation to work to detect touch events. Basically, I want to handle swiping inside of a Frame (issue is not the Frame, also tried a rectangle as a test and didn't work also). I CANNOT get any of the events in the code behind to fire when I run the app and try to swipe with my finger or use my mouse. Have tried on multiple devices as well as multiple approaches. For the most part, I am following everything I read on SO and MSDN which makes it even more frustrating. What am I missing here???
This is the XAML for the page. In this example, I set the event handler explicitly in the XAML. However, I have also tried creating it in the code behind for the control. Neither work.
<!--<Rectangle Name="TouchArea" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" ManipulationMode="All"/>-->
<Frame Name="MainPageFrame" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" ManipulationMode="All" ManipulationStarted="MainPageFrame_OnManipulationStarted">
</Frame>
Then in the code
private void MainPageFrame_OnManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
}
Have also tried this:
public MainPage()
{
this.InitializeComponent();
MainPageFrame.ManipulationInertiaStarting += MainPageFrame_ManipulationInertiaStarting;
}
private void MainPageFrame_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingRoutedEventArgs e)
{
if (e.Cumulative.Translation.X >= 300)
{
//Swipe Right
e.Handled = true;
}
if (e.Cumulative.Translation.X <= 300)
{
//Swipe Left
e.Handled = true;
}
}
Ultimately all I am trying to do is detect when a user swipes inside the frame, with inertia right or left, so I can change Frame.Navigate. This would be similar to how Pivot works but I cannot use Pivot so I am trying to do this instead.
Thanks!
Try to set Background="Transparent"
for your frame or other element on which you're tracking manipulation. When there is no background set, manipulation events might not be registered properly.