본문 바로가기

Programing (프로그래밍)/WPF & C# (C Sharp)

WPF & C# - 간단하게 Loading 표현하기 ( 로딩 이미지 / 대기중 / 이미지 / 로테이션 / rotatetion / 회전 / 더블애니메이션 / DoubleAnimation )

728x90
반응형


 WPF & C# - 간단하게 Loading 표현하기 ( 로딩 이미지 / 대기중 / 이미지 / 로테이션 / rotatetion / 회전 / 더블애니메이션 / DoubleAnimation )



loading.zip



MainWindow.xaml



1
2
3
4
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
    <Image x:Name="imgLoading" HorizontalAlignment="Center" Height="130" VerticalAlignment="Center" Width="130" Source="loding.png"/>
    <Label Content="Loading" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" FontWeight="Bold" />
</Grid>
cs



MainWindow.xaml.cs



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public MainWindow()
{
InitializeComponent();
 
// 애니메이션 설정
DoubleAnimation dba1 = new DoubleAnimation();  // 애니메이션 생성
dba1.From = 0;   // start 값
dba1.To = 360;   // end 값
dba1.Duration = new Duration(TimeSpan.FromSeconds(1));  // 1.5초 동안 실행
dba1.RepeatBehavior = RepeatBehavior.Forever;  // 무한 반복
 
RotateTransform rt = new RotateTransform();
imgLoading.RenderTransform = rt;
rt.CenterX += imgLoading.Width / 2;
rt.CenterY += imgLoading.Height / 2;
 
rt.BeginAnimation(RotateTransform.AngleProperty, dba1);   // 변경할 속성값, 대상애니매이션
}
cs




728x90
반응형