Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>One way to do this is to have a single wide grid, and have two render transforms (TranslateTransform specifically) - one for the left content, and one for the right content. The "left" content would have a TranslateTransform X value of 0, while the right one would have an X value of 480, effectively creating a double wide grid. To perform a side, just use a Storyboard with a double animation of -480 to the X value of both transforms.</p> <p>It sounds a little complicated but it's not too bad, let me know if you need more details!</p> <p>XAML:</p> <pre><code>&lt;Grid x:Name="LayoutRoot" Background="Transparent"&gt; &lt;Grid.Resources&gt; &lt;Storyboard x:Key="SlideLeftStoryboard"&gt; &lt;DoubleAnimation From="0" To="-480" Duration="0:0:0.5" Storyboard.TargetName="BlueTransform" Storyboard.TargetProperty="X"&gt; &lt;/DoubleAnimation&gt; &lt;DoubleAnimation From="480" To="0" Duration="0:0:0.5" Storyboard.TargetName="RedTransform" Storyboard.TargetProperty="X"&gt; &lt;/DoubleAnimation&gt; &lt;/Storyboard&gt; &lt;Storyboard x:Key="SlideRightStoryboard"&gt; &lt;DoubleAnimation From="-480" To="0" Duration="0:0:0.5" Storyboard.TargetName="BlueTransform" Storyboard.TargetProperty="X"&gt; &lt;/DoubleAnimation&gt; &lt;DoubleAnimation From="0" To="480" Duration="0:0:0.5" Storyboard.TargetName="RedTransform" Storyboard.TargetProperty="X"&gt; &lt;/DoubleAnimation&gt; &lt;/Storyboard&gt; &lt;/Grid.Resources&gt; &lt;Border Name="BlueBorder" Background="Blue"&gt; &lt;Border.RenderTransform&gt; &lt;TranslateTransform x:Name="BlueTransform" X="0"&gt; &lt;/TranslateTransform&gt; &lt;/Border.RenderTransform&gt; &lt;Button Click="SlideLeft_Click"&gt; &lt;TextBlock&gt; Slide Left &lt;/TextBlock&gt; &lt;/Button&gt; &lt;/Border&gt; &lt;Border Name="RedBorder" Background="Red"&gt; &lt;Border.RenderTransform&gt; &lt;TranslateTransform x:Name="RedTransform" X="480"&gt; &lt;/TranslateTransform&gt; &lt;/Border.RenderTransform&gt; &lt;Button Click="SlideRight_Click"&gt; &lt;TextBlock&gt; Slide Right &lt;/TextBlock&gt; &lt;/Button&gt; &lt;/Border&gt; &lt;/Grid&gt; </code></pre> <p>Code Behind:</p> <pre><code>public partial class MainPage : PhoneApplicationPage { Storyboard slideLeftStoryboard; Storyboard slideRightStoryboard; // Constructor public MainPage() { InitializeComponent(); this.Loaded += new RoutedEventHandler(MainPage_Loaded); } void MainPage_Loaded(object sender, RoutedEventArgs e) { slideLeftStoryboard = LayoutRoot.Resources["SlideLeftStoryboard"] as Storyboard; slideRightStoryboard = LayoutRoot.Resources["SlideRightStoryboard"] as Storyboard; } private void SlideLeft_Click(object sender, RoutedEventArgs e) { slideLeftStoryboard.Begin(); } private void SlideRight_Click(object sender, RoutedEventArgs e) { slideRightStoryboard.Begin(); } } </code></pre>
 

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