Compiling xaml using Roslyn

Story: is there a way to use the Roslyn compiler to compile UserControl WPF?

  • Suppose you want to compile an assembly containing standard C # code and WPF controls (XAML and xaml.cs files) without any csproj, of course.

  • I found a lot on the Internet about how to compile DLL with Roslyn, nothing about how to handle XAML files?

  • I know that Visual Studio (or MSBuild) creates a temporary generated file and embeds the BAML file in the resulting assembly. So maybe if I could find a way to generate this intermediate file, I could use it, but all I found is PresentationBuildTasks.MarkupCompilePass, which ultimately needs csproj (well, I can create a project on the fly "but I hope to find something simpler.)

Thanks for any help.

+2
source share
1 answer

If you want to compile XAML in C #, see the Behind Generator XAML code, see http://xamlgenerator.codeplex.com/ .

Visual Studio 2010, XAML #.

+1

Source: https://habr.com/ru/post/1544068/


All Articles