Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Non Rectangular simple splash screen WPF

0.00/5 (No votes)
6 Dec 2012 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:

 <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:

 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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here