English 中文(简体)
自动生成xaml资源字典
原标题:Autogenerating xaml ResourceDictionary

我有一个应用程序,在这个应用程序中,我为我的字符串使用了一个特定的ResourceDictionary,我需要将该ResourceDictionary的键作为字符串常量复制到类中。虽然复制和粘贴很容易,但我预计大约有350个资源字符串,而且必须管理两个包含所有内容的文件是不可能的。

我想编写一个应用程序,它有一个Key/Value网格,用户可以在其中输入值,该应用程序将在Xaml文件和.cs常量类中写入。我对.cs文件没有问题,但有没有一种方法可以在写入新文件的内容之前,在不清除文件的情况下写入一个xaml文件?

谢谢

最佳回答

您可以编写一个T4模板,该模板使用简单的设计器(WPF用户控件)或xml文件来生成xaml和C#文件。

Oleg Sych的优秀T4教程

以下是如何使用T4生成多个文件

问题回答

我在VS11中使用ReSharper 7 beta(尽管旧版本具有相同的功能)来创建一个模板,该模板至少可以减少所需的击键次数。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签