title: Programmatically bind property to GridViewColumn.Width
body: <p>I got a WPF MVVM application containing a ListView containing a GridView.<br>
  Using a helper class I'm creating the GridViewColumn's, which works nicely.</p>
  
  <p>My problem: I want to twoway-bind the width so I can read back changes to the width.</p>
  
  <p>The code to create the GridViewColumn right now looks like this:</p>
  
  <pre><code>private static GridViewColumn CreateColumn(GridView gridView, object columnSource)
  {
    GridViewColumn column = new GridViewColumn();
    String headerTextMember = GetHeaderTextMember(gridView);
    String displayMemberMember = GetDisplayMemberMember(gridView);
    String widthMember = GetWidthMember(gridView);
    // set header
    column.Header = GetPropertyValue(columnSource, headerTextMember);
  
    // set display binding
    String propertyName = GetPropertyValue(columnSource, displayMemberMember) as String;
    column.DisplayMemberBinding = new Binding(propertyName);
  
    // bind with - but how?
    //Binding widthBinding = new Binding(widthMember);
    //widthBinding.Source = columnSource;
    //widthBinding.Mode = BindingMode.TwoWay;
    //gridView.SetBinding(GridViewColumn.WidthProperty, widthBinding); &lt;- gridView got no SetBinding :(
    }
    return column;
  }
  </code></pre>
  
  <p>Anyone got some pointers for me how I might be able to bind the width?</p>