🕒 Reading Time: 05-10 Minutes
The following is a small, quick, non-exhaustive resource to help you get started with the Reloaded.WPF library - providing an introduction to using the library. This serves as a guide to help you get going, covering the basics and essentials.
- Open/Create project in Visual Studio.
- Right-click your project within the
Solution Explorer
and selectManage NuGet Packages
. - Search for
Reloaded.WPF.Theme.Default
. - Install the package.
Note: The default theme is not compulsory, you may simply use the core Reloaded.WPF
package for the utilities only if desired.
Add the theme into the application's main Resource Dictionary as follows.
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Reloaded.WPF.Controls;assembly=Reloaded.WPF"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Reloaded.WPF;component/Resources.xaml"/>
<!-- This dictionary switches locations between design and runtime -->
<controls:DesignTimeResourceDictionary RunTimeSource="pack://siteoforigin:,,,/Theme/Default/Root.xaml" DesignTimeSource="pack://application:,,,/Reloaded.WPF.Theme.Default;component/Theme/Default/Root.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
If you would wish for your window to inherit the base Reloaded style, including the glowing border then there are two things you need to do:
- Set window style to
ReloadedWindow
as aDynamicResource
. - Inherit window class from
ReloadedWindow
.
<default:ReloadedWindow
x:Class="Reloaded.WPF.TestWindow.MainWindow"
xmlns:default="clr-namespace:Reloaded.WPF.Theme.Default;assembly=Reloaded.WPF.Theme.Default"
...
Style="{DynamicResource ReloadedWindow}">
public partial class MainWindow : ReloadedWindow
Warning
Inheriting from ReloadedWindow
will replace your window's DataContext
, which is used by the underlying base window theme to style the window.
For now, Reloaded.WPF expects that you implement all your functionality in pages, (which can be hosted inside a singular PageHost
in the main window) although this may change in the future.
Inheriting pages is the same as inheriting windows, in this case, you should make the pages inherit ReloadedPage
instead.
Inheriting the page class provides you page support for animations on entry and exit.
<default:ReloadedPage
x:Class="Reloaded.WPF.TestWindow.Pages.ProcessPage"
xmlns:default="clr-namespace:Reloaded.WPF.Theme.Default;assembly=Reloaded.WPF.Theme.Default">
public partial class ProcessPage : ReloadedPage
If you do not wish to inherit the Reloaded theme, then simply instead inherit from PageBase
(in Reloaded.WPF.Pages) and override MakeEntryAnimations
and MakeExitAnimations
which will allow you to retain animation support.
See ReloadedPage for an example.
This is technically unrelated to Reloaded.WPF but it's very useful and not yet well known.
As you may know, .NET Core 3.X supports WinForms and WPF, but at the time of writing there is no/weak designer support for them in Visual Studio.
Well, it is possible to have a working designer and still build for .NET Core 3 without any time consuming, manual labour involving dirty hacks like adding all files as link to a separate project.
All you need to do is multi-target in your .csproj
, simply remove the <TargetFramework>
property and replace it with the <TargetFrameworks>
property, then target .NET Framework
as well as .NET Core
.
<TargetFrameworks>NET472;netcoreapp3.0</TargetFrameworks>
But make sure .NET Framework comes first!