Reputation: 1327
I am new to using WPF Storyboards, here is my code:
<StackPanel>
<Border Grid.Row="0" Background="Black" Height="40" Name="Border1"></Border>
<Grid Height="0" Name="MyGrid" Background="Green">
<Grid.Triggers>
<EventTrigger RoutedEvent="UserControl.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="MyGrid"
Storyboard.TargetProperty="Height" From="0" To="40"
Duration="0:0:1" BeginTime="0:0:0"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
</Grid>
</StackPanel>
I would like to change the event that triggers the storyboard to start to Border1.MouseEnter.
Is this possible?
Thanx
Upvotes: 0
Views: 427
Reputation: 4538
I really didn't try it, but this should work:
<StackPanel>
<StackPanel.Triggers>
<EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="Border1">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="MyGrid"
Storyboard.TargetProperty="Height" From="0" To="40"
Duration="0:0:1" BeginTime="0:0:0"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</StackPanel.Triggers>
<Border Grid.Row="0" Background="Black" Height="40" Name="Border1"></Border>
<Grid Height="0" x:Name="MyGrid" Background="Green" VerticalAlignment="Bottom"/>
</StackPanel>
Upvotes: 0
Reputation: 7573
In that case, you should move the triggers to the Border control:
<StackPanel>
<Border Grid.Row="0" Background="Black" Height="40" Name="Border1">
<Border.Triggers>
<EventTrigger RoutedEvent="Border.MouseEnter">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="MyGrid"
Storyboard.TargetProperty="Height" From="0" To="40"
Duration="0:0:1" BeginTime="0:0:0"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Border.Triggers>
</Border>
<Grid Height="0" Name="MyGrid" Background="Green">
</Grid>
Upvotes: 1