<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.Triggers>
<EventTrigger RoutedEvent="TextBox.MouseMove" SourceName="txt">
<BeginStoryboard Name="EnlargeStoryboard">
<Storyboard >
<DoubleAnimationUsingKeyFrames
Storyboard.TargetName="ell"
Storyboard.TargetProperty="(Ellipse.Width)">
<DiscreteDoubleKeyFrame
KeyTime="00:00:0.2"
Value="50" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
Storyboard.TargetName="ell"
Storyboard.TargetProperty="(Ellipse.Height)">
<DiscreteDoubleKeyFrame
KeyTime="00:00:0.2"
Value="50" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="TextBox.MouseLeave" SourceName="txt">
<BeginStoryboard Name="RecoverStoryboard">
<Storyboard >
<DoubleAnimationUsingKeyFrames
Storyboard.TargetName="ell"
Storyboard.TargetProperty="(Ellipse.Width)">
<DiscreteDoubleKeyFrame
KeyTime="00:00:0.2"
Value="30" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
Storyboard.TargetName="ell"
Storyboard.TargetProperty="(Ellipse.Height)">
<DiscreteDoubleKeyFrame
KeyTime="00:00:0.2"
Value="30" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
<StackPanel>
<TextBox x:Name="txt"></TextBox>
<Ellipse x:Name="ell" Fill="Green" Width="30" Height="30"></Ellipse>
</StackPanel>
</Grid>
</Window>
wpf 通过EventTrigger用一个控件控制另一个控件
猜你喜欢
转载自blog.csdn.net/dxm809/article/details/107451342
今日推荐
周排行