通过XAML绑定将静态只读值作为CommandParameter传递?

时间:2012-05-07 14:46:07

标签: c# wpf

我定义了以下类:

public static class A
{
      public static readonly double MyWidth = 200d;
}

如果我想将“MyWidth”作为命令参数发送到按钮,我该如何设置xaml?

<Button Caption="Large" CommandParameter="What should I type here?">

谢谢!

1 个答案:

答案 0 :(得分:6)

CommandParameter="{x:Static ns:A.MyWidth}"

其中ns已映射到相应的CLR名称空间。

相关问题