This repository has been archived by the owner on Jun 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Using OmniXAML for WPF
Daniel Kornev edited this page May 23, 2017
·
5 revisions
- Create a new project of type "WPF Application" and be sure that you select at least .NET Framework 4.5.2
- Install the NuGet package: OmniXaml.Wpf.
- Go to the Properties page of MainWindow.xaml and set the property Copy to Output Directory to either Copy always or Copy if newer.
- Delete MainWindow.xaml.cs (the code-behind file). It won't compile if you don't delete it.
- Open MainWindow.xaml and replace its content with this:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="MainWindow" Height="350" Width="525">
<TextBlock Text="Hello World!" />
</Window>
- Open App.xaml and remove the part that says
StartupUri="MainWindow.xaml"
- Open App.Xaml.cs and add this method inside the App class:
protected override void OnStartup(StartupEventArgs e)
{
var xamlLoader = new WpfXamlLoader();
Window mainWindow;
using (var stream = new FileStream("MainWindow.xaml", FileMode.Open))
{
mainWindow = (Window) xamlLoader.Load(stream);
}
mainWindow.Show();
}
Don't forget to add the using OmniXaml.Wpf;
part along with the other using statements ;)
- Run it!