【问题标题】:Is it possible to Bind Grid.RowProperty.是否可以绑定 Grid.RowProperty。
【发布时间】:2013-05-31 08:37:05
【问题描述】:

是否可以绑定Grid.RowProperty

Border bdr = new Border();
bdr.SetValue(Grid.RowProperty, new Binding("RowNo") { Mode = BindingMode.OneWay });
bdr.SetValue(Grid.ColumnProperty, new Binding("ColumnNo") { Mode = BindingMode.OneWay });

在编译时没有错误在运行时给出错误

无法在 System.Windows.Data.Binding 类型的对象上设置 System.Int32 类型的 DependencyProperty。

【问题讨论】:

    标签: silverlight c#-4.0 binding


    【解决方案1】:

    使用SetBinding 而不是SetValue。

    Border bdr = new Border();
    bdr.SetBinding(Grid.RowProperty,
        new Binding("RowNo") {
            Mode = BindingMode.OneWay
        });
    bdr.SetBinding(Grid.ColumnProperty,
        new Binding("ColumnNo") {
            Mode = BindingMode.OneWay
        });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-26
      • 2017-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多