728x90
반응형
728x170
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow" Name="window"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="800"
Height="600"
Title="DoubleAnimation 클래스 : 화면을 반짝이는 애니메이션 사용하기"
Background="#ff000000"
Foreground="#ff3ee229">
<Grid>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="96">
ANIMATION
</TextBlock>
<Canvas Panel.ZIndex="99">
<Rectangle Name="rectangle"
Width="{Binding Path=ActualWidth, ElementName=window, Mode=Default}"
Height="{Binding Path=ActualHeight, ElementName=window, Mode=Default}"
Opacity="0.4">
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Rectangle.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="rectangle"
Storyboard.TargetProperty="(Canvas.Left)"
From="-500"
To="1000"
Duration="0:0:2" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
<Rectangle.Fill>
<LinearGradientBrush
StartPoint="0 1"
EndPoint="1 1">
<GradientStop Color="Transparent" Offset="0.0" />
<GradientStop Color="LightGreen" Offset="0.50" />
<GradientStop Color="Transparent" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Canvas>
</Grid>
</Window>
728x90
▶ MainWindow.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public partial class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
InitializeComponent();
MouseDown += Window_MouseDown;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 윈도우 마우스 DOWN 처리하기 - Window_MouseDown(sender, e)
/// <summary>
/// 윈도우 마우스 DOWN 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
this.rectangle.Width = Width;
this.rectangle.Height = Height;
DoubleAnimation animation = new DoubleAnimation
{
Duration = new Duration(TimeSpan.FromSeconds(2)),
From = (-Width),
To = Width * 2
};
this.rectangle.BeginAnimation(Canvas.LeftProperty, animation);
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] x:ClassModifier 속성 사용하기 (0) | 2022.01.09 |
---|---|
[C#/WPF] ResourceDictionary 클래스 : 느슨한 XAML 스키닝 사용하기 (0) | 2022.01.09 |
[C#/WPF] ResourceDictionary 클래스 : 컴파일 및 동적 스키닝 사용하기 (기능 개선) (0) | 2022.01.09 |
[C#/WPF] ResourceDictionary 클래스 : 컴파일 및 동적 스키닝 사용하기 (0) | 2022.01.09 |
[C#/WPF] ResourceDictionary 클래스 : 컴파일 및 정적 스키닝 사용하기 (0) | 2022.01.09 |
[C#/WPF] TextBox 클래스 : KeyDown 이벤트를 사용해 ENTER 키를 누르는 경우 포커스 해제하기 (0) | 2022.01.08 |
[C#/WPF] 마이크로폰 볼륨 설정하기 (0) | 2022.01.08 |
[C#/WPF] 정렬과 필터링 가능한 데이터 가상화 사용하기 (0) | 2022.01.06 |
[C#/WPF] Page 엘리먼트 : WindowWidth/WindowHeight/WindowTitle 속성 사용하기 (0) | 2022.01.04 |
[C#/WPF] Application 클래스 : GetRemoteStream 정적 메소드를 사용해 원본 사이트 파일 XAML 페이지 로드하기 (0) | 2022.01.02 |
댓글을 달아 주세요