【发布时间】:2017-07-06 19:55:07
【问题描述】:
我正在尝试在 WPF 中使用嵌套常量,但 XAML 似乎无法处理嵌套静态类。
namespace MyCommon.Constants
{
public static class Constants
{
public static class Formatting
{
public static class DateTime
{
public const string BritishDateToString = "dd-MM-yy";
}
}
}
}
导入命名空间
xmlns:constants="clr-namespace:MyCommon.Constants;assembly=MyCommon"
以下行给出错误
<DataGridTextColumn Binding="{Binding Path=Date, StringFormat={x:Static constants:Constants.Formatting.DateTime.BritishDateTimeToString}}" Header="Date" />
【问题讨论】:
-
可能是 BritishDateToString 应该是静态的
-
@Florian, const => 静态
标签: c# wpf xaml class-constants