I want to use fluent design in my custom controls when it’s possible and still support older systems. How do I do this? This requires me to change my existing XAML-files, and when I do that it won’t run in older versions of Windows.
I have solved it like this. I have added this in the App-constructor to add some global resource qualifiers:
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5))
{
ResourceContext.SetGlobalQualifierValue("Custom", "Fluent");
}
Then I created two different resource dictionaries, one for fluent and one for none fluent XAML. The files are named like this:
MyResourceDictionary.xaml
MyResourceDictionary.Custom-Fluent.xaml
You can do quite much with this. But to my knowledge it’s not possible to create custom resources based on new types like AcrylicBrush, even with conditional XAML (at least not if you want to support versions before creators update). Instead I’m using existing resources like this:
<StaticResource x:Key="MyCustomBrush"
ResourceKey="SystemControlAcrylicElementBrush" />