动画组合框弹出

编程入门 行业动态 更新时间:2024-10-27 15:25:28
本文介绍了动画组合框弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用此controltemplate为组合框的弹出动画:

i am trying to animate the popup of a combobox with this controltemplate :

<Popup x:Name="PART_Popup" AllowsTransparency="True" Grid.ColumnSpan="2" RenderTransformOrigin="0.5,0.5" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" // removed the default animation Placement="Center" VerticalAlignment="Center"> <Popup.RenderTransform> <TransformGroup> <ScaleTransform ScaleY="1" ScaleX="1"

.....

<Trigger Property="IsDropDownOpen" Value="True"> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="PART_Popup" Storyboard.TargetProperty="(ScaleTransform.ScaleX)" Duration="0:0:3" From="0" To="2" /> <DoubleAnimation Storyboard.TargetName="PART_Popup" Storyboard.TargetProperty="(ScaleTransform.ScaleY)" Duration="0:0:3" From="0" To="2" /> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> </Trigger>

但是它不起作用,当我单击组合框后,弹出窗口立即显示.

but it doesn't work, the popup shows immediatly after i click on the combobox .

请问如何做到这一点?

推荐答案

将ScaleTransform应用于弹出窗口的根元素,而不是设置Popup元素本身的RenderTransform属性.请参考以下示例代码:

Apply the ScaleTransform on the root element of the Popup instead of setting the RenderTransform property of the Popup element itself. Please refer to the following sample code: <Popup x:Name="PART_Popup" AllowsTransparency="True" Grid.ColumnSpan="2" RenderTransformOrigin="0.5,0.5" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" Placement="Center" VerticalAlignment="Center"> <Grid x:Name="grid"> <Grid.RenderTransform> <TransformGroup> <ScaleTransform ScaleY="1" ScaleX="1" /> </TransformGroup> </Grid.RenderTransform> <TextBlock x:Name="tblock" Background="Yellow" FontSize="20">test...</TextBlock> </Grid> </Popup>

<Trigger Property="IsDropDownOpen" Value="True"> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="grid" Storyboard.TargetProperty="RenderTransform.Children[0].ScaleX" Duration="0:0:3" From="0" To="2" /> <DoubleAnimation Storyboard.TargetName="grid" Storyboard.TargetProperty="RenderTransform.Children[0].ScaleY" Duration="0:0:3" From="0" To="2" /> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> </Trigger>

希望有帮助.

请记住,通过将有用的帖子标记为答案来关闭话题,然后在遇到新问题时开始新话题.请不要在同一线程中问几个问题.

Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

更多推荐

动画组合框弹出

本文发布于:2023-10-06 19:14:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1467621.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组合   弹出   动画

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!