我正在尝试将 WPF 文本框的 Maxlength 属性绑定到类深处的已知常量。我正在使用 c#。
该类的结构与以下内容不太相似:
namespace Blah
{
public partial class One
{
public partial class Two
{
public string MyBindingValue { get; set; }
public static class MetaData
{
public static class Sizes
{
public const int Length1 = 10;
public const int Length2 = 20;
}
}
}
}
}
是的,它嵌套得很深,但不幸的是,在这种情况下,如果不需要大量的重写,我就无法移动很多东西。
我希望我能够将文本框 MaxLength 绑定到 Length1 或 Length2 值,但我无法让它工作。
我期望绑定类似于以下内容:
<Textbox Text="{Binding Path=MyBindingValue}" MaxLength="{Binding Path=Blah.One.Two.MetaData.Sizes.Length1}" />
任何帮助表示赞赏。
非常感谢