Reputation: 163
I have a grid control .On button click this grid will be visible.In the back end code I added child element to the grid in the button click .I want this grid to be loaded in specific pattern with certain animation. Please suggest a solution
<Grid x:Name="menuholder" Height="Auto" Canvas.ZIndex="1"
Grid.RowSpan="5" HorizontalAlignment="Right"
VerticalAlignment="Top" Margin="0,0,15,0">
</Grid>
In Back end :
MenuUserControl menu = new MenuUserControl();
menu.Visibility = Visibility.Visible;
menu.HorizontalAlignment = HorizontalAlignment.Left;
menu.VerticalAlignment = VerticalAlignment.Top;
menu.Width = 200;
menuholder.Children.Add(menu);
menuholder.Visibility = Visibility.Visible;
isMenuVisible = false;
Canvas.SetZIndex(menu, 2);
Upvotes: 0
Views: 424
Reputation: 261
You can create a Storyboard for the Grid
Sample
<phone:PhoneApplicationPage
x:Class="TestApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
<TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid x:Name="grdAnimated" Background="Red" HorizontalAlignment="Right" Height="100" Width="200">
<Grid.Resources>
<Storyboard x:Name="grdStoryBoard">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="grdAnimated">
<EasingDoubleKeyFrame KeyTime="0" Value="900"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<Grid.RenderTransform>
<CompositeTransform TranslateY="900" />
</Grid.RenderTransform>
</Grid>
</Grid>
</Grid>
</phone:PhoneApplicationPage>
In your xaml.cs code
Begin the Storyborad on your button action like:
grdStoryBoard.Begin();
You can change your animation type accordingly Refer : http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206955(v=vs.105).aspx
Storyboard can be well created with the help of Blend Refer: http://msdn.microsoft.com/en-us/library/windows/apps/jj129478.aspx
Upvotes: 2