【发布时间】:2011-07-28 09:20:29
【问题描述】:
我有以下代码
public static class StaticClass
{
public static Instance Inst { get; set; }
}
public class Instance
{
public Button Butt { get; set; }
}
我需要绑定到附加到Butt 按钮的Grid.Row 属性。我试过这个:
{Binding Source={x:Static local:StaticClass.Inst.Butt}, Path=(Grid.Row)}
但它不起作用,因为Butt 不是静态属性。通常我使用 x:Static 绑定到静态属性并将其余部分写入 Path 中,但在这种情况下 Path 包含附加属性。我不知道该怎么做。
【问题讨论】:
-
请不要将 Button 缩写为 Butt,这让我傻笑。想想后果,比如
Butt is inaccesable due to its protection level:)
标签: c# .net wpf xaml data-binding