访问嵌套的静态常量
Accessing nested static const
我正在尝试在 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" />
使用 +
访问嵌套 类
<DataGridTextColumn Binding="{Binding Path=Date, StringFormat={x:Static constants:Constants+Formatting+DateTime.BritishDateTimeToString}}" Header="Date" />
我正在尝试在 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" />
使用 +
访问嵌套 类
<DataGridTextColumn Binding="{Binding Path=Date, StringFormat={x:Static constants:Constants+Formatting+DateTime.BritishDateTimeToString}}" Header="Date" />