728x90
반응형
728x170
■ TextBox 엘리먼트의 Text 속성 변경시 애니메이션을 사용하는 방법을 보여준다.
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="800"
Height="600"
Title="TextBox 엘리먼트 : Text 속성 변경시 애니메이션 사용하기"
FontFamily="나눔고딕코딩"
FontSize="16">
<Grid>
<Grid.Resources>
<SolidColorBrush x:Key="BlackSolidColorBrushKey" Color="Black" />
<SolidColorBrush x:Key="WhiteSolidColorBrushKey" Color="White" />
</Grid.Resources>
<TextBox
Width="150"
Height="25"
VerticalContentAlignment="Center">
<TextBox.Effect>
<DropShadowEffect
BlurRadius="0"
ShadowDepth="0"
Opacity="0"
Color="White" />
</TextBox.Effect>
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<EventTrigger RoutedEvent="TextChanged">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<ThicknessAnimation
Storyboard.TargetProperty="BorderThickness"
AutoReverse="True"
Duration="00:00:02"
From="1"
To="2" />
<DoubleAnimation
Storyboard.TargetProperty="Effect.Opacity"
To="1" />
<ColorAnimation
Storyboard.TargetProperty="Effect.Color"
RepeatBehavior="2x"
AutoReverse="True"
Duration="00:00:02"
From="Red"
To="Purple" />
<DoubleAnimation
Storyboard.TargetProperty="Effect.ShadowDepth"
RepeatBehavior="2x"
AutoReverse="True"
Duration="00:00:02"
From="0"
To="1" />
<DoubleAnimation
Storyboard.TargetProperty="Effect.BlurRadius"
RepeatBehavior="2x"
AutoReverse="True"
Duration="00:00:02"
From="0"
To="30" />
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource BlackSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:1" Value="{StaticResource WhiteSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:2" Value="{StaticResource BlackSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:3" Value="{StaticResource WhiteSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:4" Value="{StaticResource BlackSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:5" Value="{StaticResource WhiteSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:6" Value="{StaticResource BlackSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:7" Value="{StaticResource WhiteSolidColorBrushKey}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource WhiteSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:1" Value="{StaticResource BlackSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:2" Value="{StaticResource WhiteSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:3" Value="{StaticResource BlackSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:4" Value="{StaticResource WhiteSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:5" Value="{StaticResource BlackSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:6" Value="{StaticResource WhiteSolidColorBrushKey}" />
<DiscreteObjectKeyFrame KeyTime="0:0:7" Value="{StaticResource BlackSolidColorBrushKey}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
</Grid>
</Window>
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] IMultiValueConverter 인터페이스 : 상대 위치 변환자 사용하기 (0) | 2021.02.27 |
---|---|
[C#/WPF] IMultiValueConverter 인터페이스 : 사각형 변환자 사용하기 (0) | 2021.02.26 |
[C#/WPF] IValueConverter 인터페이스 : 높이→반경 변환자 사용하기 (0) | 2021.02.26 |
[C#/WPF] AnimationTimeline 클래스 : 커스텀 브러시 애니메이션 사용하기 (0) | 2021.02.26 |
[C#/WPF] UI 자동화 사용하기 (0) | 2021.02.25 |
[C#/WPF] Storyboard 엘리먼트 : 행진하는 개미, 펄스, 뒤집기, 탄성 줄, 나이트 라이더 애니메이션 사용하기 (0) | 2021.02.25 |
[C#/WPF] VisualStateManager 엘리먼트 : 커스텀 CheckBox 엘리먼트 정의하기 (0) | 2021.02.22 |
[C#/WPF] DropShadowEffect 엘리먼트 사용하기 (0) | 2021.02.21 |
[C#/WPF] RichTextBox 클래스 : RTF 파일 로드하기 (0) | 2021.02.21 |
[C#/WPF] FocusManager 클래스 : SetFocusedElement 정적 메소드를 사용해 논리적 포커스 설정하기 (0) | 2021.02.21 |
댓글을 달아 주세요