【问题标题】:WPF How to bind GridView column width in code?WPF如何在代码中绑定GridView列宽?
【发布时间】:2010-11-10 18:32:49
【问题描述】:

我需要绑定在代码中动态创建的 GridView 列的 width 属性。

由于 GridViewColumn 对象没有 SetBinding 方法,我该怎么做呢?

提前致谢。

【问题讨论】:

    标签: wpf gridview listview binding


    【解决方案1】:

    【讨论】:

    • 终于有一些可行的方法了,谢谢。不再需要这个,但有一天会尝试。
    【解决方案2】:

    您可以在负责更改列的宽度状态的事件处理程序中执行 SetValue 并以这种方式进行更新。

    【讨论】:

      【解决方案3】:
      GridViewColumn gvc = new GridViewColumn();
      gvc.Header = "Value";
      Binding b = new Binding();
      b.XPath = "./Data/@Value";
      gvc.DisplayMemberBinding = b;
      GridView.Columns.Add(gvc);
      

      【讨论】:

        猜你喜欢
        • 2010-10-29
        • 2010-11-18
        • 1970-01-01
        • 1970-01-01
        • 2013-10-11
        • 1970-01-01
        • 1970-01-01
        • 2017-05-20
        • 2016-11-21
        相关资源
        最近更新 更多