我有以下代码
public static class StaticClass
{
public static Instance Inst { get; set; }
}
public class Instance
{
public Button Butt { get; set; }
}
我需要绑定到Grid.Row
按钮附加的Butt
属性。我试过这个:
{Binding Source={x:Static local:StaticClass.Inst.Butt}, Path=(Grid.Row)}
但它不起作用,因为Butt
不是静态属性。通常我使用x:Static绑定到静态属性并将其余部分写入Path,但在这种情况下,Path包含附加属性。我不知道该怎么做。
答案 0 :(得分:4)
你需要这个,因为正如你所说,Butt
不是静态的:
{Binding Source={x:Static local:StaticClass.Inst}, Path=Butt.(Grid.Row)}
也就是说,将Butt
作为Path
的一部分,而不是Source
的一部分。