【发布时间】:2011-04-24 13:22:49
【问题描述】:
假设我有一个类定义如下:
namespace MyProject.MyConstants
{
public class Constants
{
public class Group1Constants
{
public const string DoIt= "DoIt";
}
}
}
我正在尝试在我的 xaml 中使用来自单独项目的这个 const。我包含了命名空间:
xmlns:constants="clr-namespace:MyProject.MyConstants;assembly=MyProject.MyConstants"
我正在尝试按如下方式使用常量:
<MenuItem Header="{x:Static controls:Constants.Group1Constants.DoIt}">
虽然上面不会编译,但是说
Cannot find the type 'Constants.Group1Constants'. Note that type names are case sensitive.
我一定错过了一些简单的东西。我想要做的就是在我的 xaml 中使用不同项目中的类中的一些常量。
有什么建议吗?
【问题讨论】: