Skip to content

Instantly share code, notes, and snippets.

@jossef
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jossef/c6de37e25bbaeaa7e029 to your computer and use it in GitHub Desktop.
Save jossef/c6de37e25bbaeaa7e029 to your computer and use it in GitHub Desktop.
<Application x:Class="WpfApplication2.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
</Application.Resources>
</Application>
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace WpfApplication2
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
async protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// Create and show SplashWindow
SplashWindow splashWindow = new SplashWindow();
splashWindow.Show();
// Let's wait 3 seconds
await Task.Delay(3000);
// Create and show the SelectionWindow
SelectionWindow selectionWindow = new SelectionWindow();
selectionWindow.Show();
// Hide the SplashWindow we previosly created
splashWindow.Close();
}
}
}
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<Label>This is the main window :)</Label>
</StackPanel>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml.Linq;
namespace WpfApplication2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
<Window x:Class="WpfApplication2.SelectionWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="SelectionWindow" Height="300" Width="300">
<StackPanel>
<Button Click="Button_Click">Click to open MainWindow</Button>
</StackPanel>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace WpfApplication2
{
/// <summary>
/// Interaction logic for SelectionWindow.xaml
/// </summary>
public partial class SelectionWindow : Window
{
public SelectionWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
// Create and show MainWindow
var mainWindow = new MainWindow();
mainWindow.Show();
// Closes SelectionWindow
this.Close();
}
}
}
<Window x:Class="WpfApplication2.SplashWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="SplashWindow" Height="300" Width="300">
<StackPanel>
<Label FontSize="50">Splash Screen</Label>
</StackPanel>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace WpfApplication2
{
/// <summary>
/// Interaction logic for SplashWindow.xaml
/// </summary>
public partial class SplashWindow : Window
{
public SplashWindow()
{
InitializeComponent();
}
}
}
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// Create and show SplashWindow
SplashWindow splashWindow = new SplashWindow();
splashWindow.Show();
var thread = new System.Threading.Thread(p =>
{
System.Threading.Thread.Sleep(3000);
Dispatcher.Invoke(() =>
{
// Create and show the SelectionWindow
SelectionWindow selectionWindow = new SelectionWindow();
selectionWindow.Show();
// Hide the SplashWindow we previosly created
splashWindow.Close();
});
});
thread.Start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment