-
[WPF]LoadingSpinnerC#/WPF 2023. 6. 13. 09:39
Using GIF image as animation:
You can also use a GIF image as a loading indicator in your project. The WPF does not support animating the GIF image as default, if you try to use it just like JPG or PNG image, it will not animate. Fortunately, there is a NuGet package called WpfAnimatedGif which can animate the GIF images. Let’s see how to make use of it.
First of all, install WpfAnimatedGif, for this, go to Tools > Nuget Package Manager > Package Manager Console, then type Install-Package WpfAnimatedGif, then in MainWindow.xaml file, add xmlns:gif=”http://wpfanimatedgif.codeplex.com” as XML namespace. after that, add the GIF image in your project, remove progress bar control and finally, create an image control as follows:
<Image Name="imgCircle" Visibility="Collapsed" Width="100" Height="100" gif:ImageBehavior.AnimatedSource="/circle.gif" />The complete MainWindow.xaml file will look like this:
<Window x:Class="LoadingAnimation.MainWindow"xmlns:local="clr-namespace:LoadingAnimation"mc:Ignorable="d"Title="MainWindow" Height="300" Width="300"><Grid><Image Name="imgCircle" Visibility="Collapsed" Width="100" Height="100" gif:ImageBehavior.AnimatedSource="/circle.gif" /><Button Name="PerformTask" Content="Execute job" Click="PerformTask_Click" Margin="110,50,0,0" Width="80" Height="20" HorizontalAlignment="Left" VerticalAlignment="Top"/></Grid></Window>Now run the project, the output of the project will look like this:
https://dottutorials.net/wpf-loading-animation-in-net-core-3/
https://github.com/shehryarkn/Loading-Animation-DotNet-Core-3-WPF
https://it-delinquent.medium.com/wpf-spinning-image-loading-wheel-62185a4317c
728x90'C# > WPF' 카테고리의 다른 글
[WPF] 프로세스간 메시지 전달 (0) 2023.06.20 [WPF] URL (0) 2023.06.13 [WPF] ShellExecute (0) 2023.06.09 [WPF] Platform (0) 2023.06.07 [WPF] PostBuildEvent (0) 2023.06.01 댓글