问题描述
- wpf 数据模板后台绑定事件的问题
-
GridViewColumn column = new GridViewColumn();
GridViewColumnHeader h = new GridViewColumnHeader();
h.Content = "??????";
h.Tag = "*******";
column.Header = h;
DataTemplate dt = new DataTemplate();
FrameworkElementFactory fef = new FrameworkElementFactory(typeof(CheckBox));
Binding binding = new Binding();
binding.Path = new PropertyPath("MarketIndicator");
fef.SetBinding(CheckBox.ContentProperty, binding);
fef.SetValue(CheckBox.ForegroundProperty, Brushes.White);
dt.VisualTree = fef;
column.CellTemplate = dt;
//-----------------------网上找的这段代码,是可以fef.SetValue来给CheckBox属性赋值,
但是如果fef.SetValue(CheckBox.ClickEvent,?); ?位置放什么才对呢,显示是object可是放上我写的事件函数名还是委托都是错误呢???,求如何给上层元素添加事件??
解决方案
时间: 2024-11-01 13:54:44