Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 16th, 2012  |  syntax: None  |  size: 4.30 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Easiest Way to Animate Control from Hidden to Full Size?
  2. _______
  3.    |G|G|G|
  4.    -------
  5.        
  6. _______________
  7. |G|G|B|B|B|B|G|
  8. ---------------
  9.        
  10. <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  11.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  12.     xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
  13.     xmlns:System="clr-namespace:System;assembly=mscorlib"
  14.     xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
  15.     x:Class="Example.MainWindow"
  16.     Title="MainWindow"
  17.     Height="350"
  18.     Width="525">
  19. <Grid>
  20.     <VisualStateManager.VisualStateGroups>
  21.         <VisualStateGroup x:Name="Group1" ei:ExtendedVisualStateManager.UseFluidLayout="True">
  22.             <VisualStateGroup.Transitions>
  23.                 <VisualTransition GeneratedDuration="0:0:1"/>
  24.             </VisualStateGroup.Transitions>
  25.             <VisualState x:Name="G1Hidden">
  26.                 <Storyboard>
  27.                     <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="button">
  28.                         <DiscreteObjectKeyFrame KeyTime="0">
  29.                             <DiscreteObjectKeyFrame.Value>
  30.                                 <System:Double>0</System:Double>
  31.                             </DiscreteObjectKeyFrame.Value>
  32.                         </DiscreteObjectKeyFrame>
  33.                     </ObjectAnimationUsingKeyFrames>
  34.                     <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="button1">
  35.                         <DiscreteObjectKeyFrame KeyTime="0">
  36.                             <DiscreteObjectKeyFrame.Value>
  37.                                 <System:Double>0</System:Double>
  38.                             </DiscreteObjectKeyFrame.Value>
  39.                         </DiscreteObjectKeyFrame>
  40.                     </ObjectAnimationUsingKeyFrames>
  41.                 </Storyboard>
  42.             </VisualState>
  43.             <VisualState x:Name="G1Shown"/>
  44.         </VisualStateGroup>
  45.         <VisualStateGroup x:Name="Group2" ei:ExtendedVisualStateManager.UseFluidLayout="True">
  46.             <VisualStateGroup.Transitions>
  47.                 <VisualTransition GeneratedDuration="0:0:1"/>
  48.             </VisualStateGroup.Transitions>
  49.             <VisualState x:Name="G2Hidden">
  50.                 <Storyboard>
  51.                     <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="button2">
  52.                         <DiscreteObjectKeyFrame KeyTime="0">
  53.                             <DiscreteObjectKeyFrame.Value>
  54.                                 <System:Double>0</System:Double>
  55.                             </DiscreteObjectKeyFrame.Value>
  56.                         </DiscreteObjectKeyFrame>
  57.                     </ObjectAnimationUsingKeyFrames>
  58.                     <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="button3">
  59.                         <DiscreteObjectKeyFrame KeyTime="0">
  60.                             <DiscreteObjectKeyFrame.Value>
  61.                                 <System:Double>0</System:Double>
  62.                             </DiscreteObjectKeyFrame.Value>
  63.                         </DiscreteObjectKeyFrame>
  64.                     </ObjectAnimationUsingKeyFrames>
  65.                 </Storyboard>
  66.             </VisualState>
  67.             <VisualState x:Name="G2Shown"/>
  68.         </VisualStateGroup>
  69.     </VisualStateManager.VisualStateGroups>
  70.     <VisualStateManager.CustomVisualStateManager>
  71.         <ei:ExtendedVisualStateManager/>
  72.     </VisualStateManager.CustomVisualStateManager>
  73.     <i:Interaction.Behaviors>
  74.         <ei:DataStateBehavior Binding="{Binding IsChecked, ElementName=toggleButton}" Value="True" TrueState="G1Shown" FalseState="G1Hidden"/>
  75.         <ei:DataStateBehavior Binding="{Binding IsChecked, ElementName=toggleButton1}" Value="True" TrueState="G2Shown" FalseState="G2Hidden"/>
  76.     </i:Interaction.Behaviors>
  77.     <StackPanel Orientation="Horizontal">
  78.         <ToggleButton x:Name="toggleButton" Content="Group1" />
  79.         <Button x:Name="button" Content="Group1B1" />
  80.         <Button x:Name="button1" Content="Group1B2" />
  81.         <ToggleButton x:Name="toggleButton1" Content="Group2" />
  82.         <Button x:Name="button2" Content="Group2B1" />
  83.         <Button x:Name="button3" Content="Group2B2" />
  84.     </StackPanel>
  85. </Grid>