Click here to Skip to main content
15,886,026 members
Articles / Desktop Programming / WPF
Tip/Trick

Non Rectangular simple splash screen WPF

Rate me:
Please Sign up or sign in to vote.
3.00/5 (2 votes)
6 Dec 2012CPOL 10.1K   406   1   1
A WPF sample, edit and make your own splash

Introduction

Here is a simple XAML created splash screen for Windows application. It is quite good looking and completely editable according to your needs.

Background

In code behind, just adjust the timespan value for how much time you want to show splash.

Using the Code

The grid inside the window uses a path to make its non rectangular shape. The XAML is here:

XML
<Path Stroke="DarkGray" StrokeThickness="5" SnapsToDevicePixels="True">
               <Path.Fill>
                   <LinearGradientBrush StartPoint="0.2,0" EndPoint="0.8,1" >
                       <LinearGradientBrush.GradientStops>
                           <GradientStop Color="White"  Offset="0"></GradientStop>
                           <GradientStop Color="SkyBlue"  Offset="0.45"></GradientStop>
                           <GradientStop Color="White" Offset="0.8"></GradientStop>
                           <GradientStop Color="Gray" Offset="1"></GradientStop>
                       </LinearGradientBrush.GradientStops>
                   </LinearGradientBrush>
               </Path.Fill>
               <Path.Data>
                   <PathGeometry>
                       <PathGeometry.Figures>
                           <PathFigure StartPoint="0,0" IsClosed="True">
                               <LineSegment Point="405,0"></LineSegment>
                               <LineSegment Point="600,175"></LineSegment>
                               <LineSegment Point="400,270"></LineSegment>
                               <LineSegment Point="90,270"></LineSegment>
                               <LineSegment Point="0,170"></LineSegment>
                           </PathFigure>
                       </PathGeometry.Figures>
                   </PathGeometry>
               </Path.Data>
               <Path.RenderTransform>
                   <ScaleTransform ScaleX="1.3" ScaleY="1.3"></ScaleTransform>
               </Path.RenderTransform>

           </Path>

In code behind:

C#
private void Window_Loaded(object sender, RoutedEventArgs e)
       {
           DispatcherTimer dispatcherTimer = new DispatcherTimer();
           dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
           dispatcherTimer.Interval = new TimeSpan(0, 0, 8);
           dispatcherTimer.Start();

       }

       private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
       {
           Closing -= Window_Closing;
           e.Cancel = true;
           var anim = new DoubleAnimation(0, (Duration)TimeSpan.FromSeconds(1));
           anim.Completed += (s, _) => this.Close();
           this.BeginAnimation(UIElement.OpacityProperty, anim);
       }

       private void dispatcherTimer_Tick(object sender, EventArgs e)
       {
           this.Close();
       }

Output

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 2 Pin
BadassAlien9-Dec-12 10:43
professionalBadassAlien9-Dec-12 10:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.