I got a WPF MVVM application containing a ListView containing a GridView.
Using a helper class I'm creating the GridViewColumn's, which works nicely.
My problem: I want to twoway-bind the width so I can read back changes to the width.
The code to create the GridViewColumn right now looks like this:
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); <- gridView got no SetBinding :(
}
return column;
}
Anyone got some pointers for me how I might be able to bind the width?