Skip to content

Instantly share code, notes, and snippets.

@GSonofNun
Created February 17, 2014 19:05
Show Gist options
  • Save GSonofNun/9056882 to your computer and use it in GitHub Desktop.
Save GSonofNun/9056882 to your computer and use it in GitHub Desktop.
private void Grid_Hold(object sender, System.Windows.Input.GestureEventArgs e)
{
Grid g = (Grid)sender;
// This throws an error because you can't pass a Grid as a Control in the first parameter
VisualStateManager.GoToState(g, "Context", true);
}
<DataTemplate x:Key="ItemTemplate1">
<Grid Hold="Grid_Hold" >
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ContextGrid">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Context">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ContextGrid">
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<!-- Main Content -->
<Grid x:Name="ContextGrid" Background="#99000000" Visibility="Collapsed">
<!-- Context Content -->
</Grid>
</Grid>
</DataTemplate>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment