Hi,
I'm trying to programmatically assign a header template for a column. The header template is similar to the GridViewSelectColumn as it just would have a checkbox in it, but I need the column to be able to bind to a property. I did look at the blog post from Vlad, but it will not work for this particular situation.
Below is the code I have to create a custom template (which works with for an ordinary ListView), but I don't know how to programmatically assign it to the column. I tried setting it to the column.Header property since it's of type object, but that did not work.
Thank you,
Tim
I'm trying to programmatically assign a header template for a column. The header template is similar to the GridViewSelectColumn as it just would have a checkbox in it, but I need the column to be able to bind to a property. I did look at the blog post from Vlad, but it will not work for this particular situation.
Below is the code I have to create a custom template (which works with for an ordinary ListView), but I don't know how to programmatically assign it to the column. I tried setting it to the column.Header property since it's of type object, but that did not work.
FrameworkElementFactory factory =
new
FrameworkElementFactory(
typeof
(CheckBox));
factory.AddHandler(CheckBox.CheckedEvent,
new
RoutedEventHandler(GridViewAll_HeaderCheckBox_Checked));
factory.AddHandler(CheckBox.UncheckedEvent,
new
RoutedEventHandler(GridViewAll_HeaderCheckBox_Checked));
factory.SetValue(CheckBox.ToolTipProperty,
"(De)Select All"
);
DataTemplate template =
new
DataTemplate();
template.DataType =
typeof
(
bool
);
template.VisualTree = factory;
GridViewCheckBoxColumn column =
new
GridViewCheckBoxColumn();
column.DataMemberBinding =
new
Binding(prefix + property.Name);
column.Header = template
// <-- this does not work
Thank you,
Tim