I have a project that will have multiple tabs. When the user selects a tab, I would like the grid that's inside that tab to slide out. I figure I can accomplish that by changing the grids margin. I actually have a solution that works, but it requires 2 DLL's from Blend to be included. I would think the same effect is possible without using Blend but I can't figure it out. Below is the storyboard and tabItems xaml
<Storyboard x:Key="tabAdminSlide">
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="grid1">
<EasingThicknessKeyFrame KeyTime="0" Value="400,0,0,0"/>
<EasingThicknessKeyFrame KeyTime="0:0:0.5" Value="0,0,0,0">
<EasingThicknessKeyFrame.EasingFunction>
<ExponentialEase EasingMode="EaseOut"/>
</EasingThicknessKeyFrame.EasingFunction>
</EasingThicknessKeyFrame>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
<TabItem Header="Run as Admin" x:Name="tabAdmin" Background="LightBlue">
<i:Interaction.Triggers>
<ei:DataTrigger Binding="{Binding SelectedIndex, ElementName=tabControl}" Value="0">
<ei:ControlStoryboardAction Storyboard="{StaticResource tabAdminSlide}"/>
</ei:DataTrigger>
</i:Interaction.Triggers>
<Grid Height="Auto" x:Name="grid1" Width="Auto">
<Grid.Background>
<LinearGradientBrush StartPoint="-0.002,0.498" EndPoint="1.084,0.498">
<GradientStop Color="LightBlue" Offset="0.446" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</Grid.Background>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="40,179,0,0" Name="button1" VerticalAlignment="Top" Width="75" Grid.ColumnSpan="2" />
</Grid>
</TabItem>
It looks like
<i:Interaction.Triggers>
<ei:DataTrigger Binding="{Binding SelectedIndex, ElementName=tabControl}" Value="0">
<ei:ControlStoryboardAction Storyboard="{StaticResource tabAdminSlide}"/>
</ei:DataTrigger>
</i:Interaction.Triggers>
Is the part I need to replace but I can't be sure. Any help would be appriciated
Thanks.
You should be able to use
<TabItem.Triggers>
<EventTrigger RoutedEvent="Selector.Selected">
<BeginStoryboard Storyboard="{StaticResource tabAdminSlide}" />
</EventTrigger>
</TabItem.Triggers>
instead of
<i:Interaction.Triggers>
<ei:DataTrigger Binding="{Binding SelectedIndex, ElementName=tabControl}" Value="0">
<ei:ControlStoryboardAction Storyboard="{StaticResource tabAdminSlide}"/>
</ei:DataTrigger>
</i:Interaction.Triggers>