我有看起來像這樣的示例代碼。如何爲網格行高度生成動畫
<ItemsControl ItemsSource="{Binding MyDataCollection}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.Style>
<Style TargetType="Grid">
<Style.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<!--<DoubleAnimation Duration="0:0:0.100" Storyboard.Target="(Grid.RowDefinitions[2])" Storyboard.TargetProperty="Height" From="10" To="0" />-->
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Image Source="{Binding CurrentImage}" Grid.Row="0" Stretch="Uniform" />
<TextBlock Grid.Row="1" Text="{Binding Title}" TextAlignment="Center" FontSize="16" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
我想在MouseEnter事件上設置動畫行高度。在xaml中設置Storyboard.Target的正確語法是什麼?
如果我在第三行定義中放置一些自定義控件並使其像這樣會怎麼樣?將我能夠動畫這個自定義控件的高度,以達到相同的效果? –
Milos
看到我編輯的答案。 – mm8