I have the following code which I found from here:
private void Grid_ManipulationStarted_1(object sender, ManipulationStartedRoutedEventArgs e)
{
initialpoint = e.Position;
}
private void Grid_ManipulationDelta_1(object sender, ManipulationDeltaRoutedEventArgs e)
{
if (e.IsInertial)
{
Point currentpoint = e.Position;
if (currentpoint.X - initialpoint.X >= 500)//500 is the threshold value, where you want to trigger the swipe right event
{
System.Diagnostics.Debug.WriteLine("Swipe Right");
e.Complete();
}
}
}
And my Xaml:
<Page
x:Class="MyApp.DetailPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Viewbox x:Name="MainViewbox" Stretch="Uniform" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="1, 1, 1, 1" ManipulationDelta="Grid_ManipulationDelta_1" ManipulationStarted="Grid_ManipulationStarted_1">
<Grid ManipulationDelta="Grid_ManipulationDelta_1" ManipulationStarted="Grid_ManipulationStarted_1" Background='Transparent'>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="IDAndTitleTxt" HorizontalAlignment="Center" VerticalAlignment="Top" Grid.Row="1" TextAlignment="Center" Height="Auto" Width="Auto" FontSize="20" Foreground="White"/>
<TextBlock x:Name="IssueType" HorizontalAlignment="Center" VerticalAlignment="Top" Text="Code Defect" MaxHeight="10" Height="Auto" Width="Auto" Foreground="White" FontSize="4"/>
<TextBlock x:Name="UserAssignedTo" HorizontalAlignment="Center" VerticalAlignment="Top" Height="Auto" Width="Auto" Grid.Row="3" Foreground="White" FontSize="8"/>
<TextBlock x:Name="StateSubstate" HorizontalAlignment="Center" VerticalAlignment="Top" Text="Active / In Progress" Height="Auto" Width="Auto" Grid.Row="4" Foreground="White" FontSize="8"/>
<Button x:Name="BackBtn" Content="Back" HorizontalAlignment="Left" VerticalAlignment="Top" Height="40" Width="40" Grid.RowSpan="2" Grid.Row="0"/>
<ScrollViewer Height="260" Width="200" HorizontalScrollBarVisibility="Disabled" Grid.Row="2" Canvas.Top="60" Canvas.Left="340">
<TextBlock Width="195" TextWrapping="Wrap" FontSize="5" x:Name="DescriptionTxt"/>
</ScrollViewer>
</Grid>
</Viewbox>
My problem is that both the manipulation events never fire no matter how much I swipe the screen in all directions. I've put breakpoints on the event handlers to confirm this. Someone else has already asked the same question here but there is no answers. Seeing as that question was more than 2 years ago, I'm rewriting it.
Also, my grid is inside a viewbox, which is in a page (not a window).
Any help is appreciated :).
I guess you meant a Windows Phone 8.1 runtime application? Because in silverlight it works fine.
For that you should set ManipulationMode
to All
for your grid. In my test it worked fine even without a background color (which is necessary in silverlight applications).
If you need just a subset of manipulations, you should use the best mode for your needs.