罗斯林使用XAML编译 [英] Compile xaml using Roslyn
问题描述
短故事:有没有使用罗斯林编译器编译一个WPF用户控件的方式
Short story: is there a way to use Roslyn compiler to compile a WPF UserControl?
-
假设你想当然没有任何的csproj编译包含标准的C#代码和WPF控件(XAML和xaml.cs文件)的组件。
Let's say you'd want to compile an assembly containing standard C# code and WPF controls (XAML and xaml.cs files) without any csproj of course.
我发现了很多如何编译使用罗斯林如何处理XAML文件的DLL,没有在网络上?
I've found a lot on the web on how to compile a DLL using Roslyn, nothing on how to handle XAML files?
我知道的Visual Studio(或的MSBuild)创建一个临时生成的文件,并嵌入在所得组件的BAML文件。因此,也许如果我能找到一种方法来生成此中间文件,我可以使用它,但我发现是PresentationBuildTasks.MarkupCompilePass,到底需要的csproj(好吧,我可以动态生成一个项目,但我希望找到更简单的东西)。
I know that Visual Studio (or MSBuild) creates a temporary generated file and embed a 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 have found is PresentationBuildTasks.MarkupCompilePass that needs in the end a csproj (ok, I may generate a project on the fly, but I hope to find something simpler).
感谢您的帮助。
推荐答案
如果你的目标是编译XAML到C#,检查出的XAML代码生成器的背后,看到的 http://xamlgenerator.codeplex.com/ 。
If your goal is to compile XAML to C#, check out the XAML Code Behind Generator, see http://xamlgenerator.codeplex.com/.
及其对Visual Studio 2010中,可以让你XAML编译成等价的C#插件。
Its a plugin for Visual Studio 2010 that allows you to compile XAML into the equivalent C#.
这篇关于罗斯林使用XAML编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!