Reputation: 21
I am working on my UWP app. I set up:
I use some AcrylicBrushes. Because they require 16299 version, I have two files with brushes:
and I use code below in App.xaml.cs
private void SetupStyles() {
var prefix = PlatformApiService.IsAcrylicBrushAvailable ? "Fall/" : string.Empty;
var brushUri = new Uri($"ms-appx:///Styles/{prefix}Brushes.xaml", UriKind.Absolute);
Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = brushUri });
}
Everything works fine when min version is 10586, but with 14393 my app can't build because:
Type 'Windows.UI.Xaml.Media.AcrylicBrush' is defined under contract 'Windows.Foundation.UniversalApiContract' version '5.0.0.0', but the contract version for the targeted min version is '3.0.0.0'!
Member 'BackgroundSource' on type 'Windows.UI.Xaml.Media.IAcrylicBrush' is defined under contract 'Windows.Foundation.UniversalApiContract' version '5.0.0.0', but the contract version for the targeted min version is '3.0.0.0'!
Member 'FallbackColor' on type 'Windows.UI.Xaml.Media.IXamlCompositionBrushBase' is defined under contract 'Windows.Foundation.UniversalApiContract' version '4.0.0.0', but the contract version for the targeted min version is '3.0.0.0'!
I can't use Conditional XAML, becase it requires 15063 version. What should I do?
Upvotes: 2
Views: 361
Reputation: 530
You can make the assets SolidColorBrushes in the XAML and then override them to Acrylic brushes in the C#
if (ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush"))
{
var brush= ((SolidColorBrush)App.Current.Resources["ExampleBrush"]).Color;
App.Current.Resources["ExampleBrush"] = new AcrylicBrush()
{
TintOpacity = ,
TintColor = brush,
FallbackColor = brush,
BackgroundSource = AcrylicBackgroundSource.HostBackdrop
};
}
Upvotes: 3