How to compile WPF's Resource Dictionary with CSharpCompilation programmatically

Viewed 27

I need to create dll containing ResourceDictionary for WPF (.net framework) application, from data from DB in environment running on .NET Core 3.1 runtime.

Let's say, I want to add this ResourceDictionary into dll:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:system="clr-namespace:System;assembly=mscorlib">

    <system:String x:Key="theKey">Value</system:String>

</ResourceDictionary>

I tried to use CSharpCompilation, but I'm struggling on how to 'compile xaml'. Tried to add it as resource (using this answer), however it's not the same as when I compile it. Compiled resource dictionary is represented as *.g.resources file in assembly's Manifest Resources.

Any idea whether this is even possible to do with CSharpCompilation?

0 Answers
Related