【发布时间】:2012-03-30 21:13:12
【问题描述】:
我是 wpf 的菜鸟,但我有一个应用程序要编写,其中涉及在鼠标离开父容器时隐藏控件的某些边框/部分。
我已经成功地为文本框和按钮做到了,只是简单地在不透明度和边框颜色上使用故事板动画,但是组合框是一个不同的鱼壶,所以看起来,我猜这并不容易!
重申一下,我需要隐藏控件的所有使其看起来像组合框的部分,即边框和下拉箭头按钮 - 使选定的文本可见。最好带有动画,当鼠标离开它的父容器时。 此 xaml 显示了 TextBox 的触发器:
<Grid.Triggers>
<EventTrigger RoutedEvent="Grid.MouseEnter">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource showTextbox}"/>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="Grid.MouseLeave">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource hideTextbox}"/>
</EventTrigger.Actions>
</EventTrigger>
</Grid.Triggers>
这个 xaml 是动画的故事板。
<Storyboard x:Key="showTextbox" >
<ColorAnimation Storyboard.TargetName="textBox1" Storyboard.TargetProperty="(TextBox.BorderBrush).Color" From="White" To="Black" Duration="0:0:0.25" AutoReverse="False" />
</Storyboard>
<Storyboard x:Key="hideTextbox" >
<ColorAnimation Storyboard.TargetName="textBox1" Storyboard.TargetProperty="(TextBox.BorderBrush).Color" From="Black" To="White" Duration="0:0:0.25" AutoReverse="False" />
</Storyboard>
感谢您对此的任何帮助或指点!
【问题讨论】: