Note that there are some explanatory texts on larger screens.

plurals
  1. POHandling horizontal swipe on control in WinRT
    primarykey
    data
    text
    <p>So let's say I have stackpanel on the left edge with width 200px. Now I want to handle horizontal swipe from left to right on this panel and show additional panel. Then handle swipe from right to left to hide it.</p> <p>I tried handling page's <code>ManipulationStarted</code> and <code>ManipulationDelta</code> events, but it doesn't seem to have any effect at least with mouse. Any ideas, what could be an easy way to implement that?</p> <p>What I've tried: Handle page's swipe events and on the beginning of swipe check, if it was started in bounds of stackpanel, else I ignore it.</p> <p>If swipe's delta was more then positive 40, looks like swipe was from left to right.</p> <p>My XAML file:</p> <pre><code>// standard stuff of page &lt;Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"&gt; &lt;StackPanel Orientation="Vertical" Width="200" HorizontalAlignment="Left" Background="White" x:Name="Panel"/&gt; &lt;/Grid&gt; </code></pre> <p>// continue standard stuff</p> <p>C# file:</p> <pre><code> public MainPage() { this.InitializeComponent(); this.ManipulationDelta += MainPage_ManipulationDelta; this.ManipulationStarted += MainPage_ManipulationStarted; } private void MainPage_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e) { System.Diagnostics.Debug.WriteLine("heh"); if (e.Position.X &lt; 200) { initialPoint = e.Position; isSwiping = true; } } private void MainPage_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) { if (e.IsInertial &amp;&amp; isSwiping) { Point currentPoint = e.Position; if (currentPoint.X - initialPoint.X &gt;= 40) { isSwiping = false; e.Complete(); System.Diagnostics.Debug.WriteLine("finished swipe :)"); } } } private Point initialPoint; private Boolean isSwiping; </code></pre> <p>(Again omitted default empty page)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload