I have a WPF application that is working just fine as written for .NET Framework targeting 4.7.2 There are several styles in the App.xaml file.
<BitmapImage x:Key="BitImageAdd" UriSource="Images/iconAdd.png" ></BitmapImage>
<BitmapImage x:Key="BitImageDelete" UriSource="Images/iconDelete.png" ></BitmapImage>
<BitmapImage x:Key="BitImageArrowUp" UriSource="Images/iconArrowUp.png" ></BitmapImage>
<BitmapImage x:Key="BitImageArrowDown" UriSource="Images/iconArrowDown.png" ></BitmapImage>
<Style TargetType="Button" x:Key="btnAdd" x:Shared="False">
<Setter Property="Content">
<Setter.Value>
<Image Source="{StaticResource BitImageAdd}"></Image>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Button" x:Key="btnDelete" x:Shared="False">
<Setter Property="Content">
<Setter.Value>
<Image Source="{StaticResource BitImageDelete}"></Image>
</Setter.Value>
</Setter>
</Style>
When I use this in the new application written in a new project for .NET CORE 5.0 I get an underline below 'BitmapImage' that says the System.Windows.Media.Imaging.BitmapImage must have IsFrozen set to false to modify. I can't set that property. If I use that for Content on a button it shows "System.Windows.Style"
Another part of the App.xaml file creates a text style that's used later in data grid.
<Style TargetType="{x:Type DataGridRow}" x:Key="BatchStateRowStyle">
<Style.Resources>
<LinearGradientBrush x:Key="Hold" StartPoint="0,0" EndPoint="0,1" >
<GradientStop Offset="0.35" Color="#FF4F4F4F" />
<GradientStop Offset="0.5" Color="Purple" />
<GradientStop Offset="0.65" Color="#FF4F4F4F" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="Sent" StartPoint="0,0" EndPoint="0,1" >
<GradientStop Offset="0.35" Color="#FF4F4F4F" />
<GradientStop Offset="0.5" Color="Purple" />
<GradientStop Offset="0.65" Color="#FF4F4F4F" />
</LinearGradientBrush>
... more styles
</Style.Resources>
<Style.Triggers>
<DataTrigger Binding="{Binding State}" Value="3">
<Setter Property="Background" Value="{StaticResource Hold}" />
</DataTrigger>
<DataTrigger Binding="{Binding State}" Value="4">
<Setter Property="Background" Value="{StaticResource Sent}" />
</DataTrigger>
... more triggers
<Style.Triggers>
In this case the underlined word is the Style at the top which says that StaticResourceExtension is not valid for Setter.Value. So it appears that it's the Setter.Value on Background that's complaining about the StaticResource of the styles defined just above.
I tried moving the BitmapImage items into their own ResourceDictionary and merging it into App.XAML but that didn't help.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Bitmap Images-->
<BitmapImage x:Key="BitImageAdd" UriSource="Images/iconAdd.png" ></BitmapImage>
<BitmapImage x:Key="BitImageDelete" UriSource="Images/iconDelete.png" ></BitmapImage>
<BitmapImage x:Key="BitImageArrowUp" UriSource="Images/iconArrowUp.png" ></BitmapImage>
<BitmapImage x:Key="BitImageArrowDown" UriSource="Images/iconArrowDown.png" ></BitmapImage>
</ResourceDictionary>
App.XAML
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ImageDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
and with that the app crashed telling me the Resources property was already set on App.
I've been looking at different options for how to use these but nothing that really explains how to make these work for .Net Core 5