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