没有合适的资源?快使用搜索试试~ 我知道了~
代码编写DataTemplate
需积分: 13 0 下载量 166 浏览量
2014-10-30
16:36:49
上传
评论
收藏 4KB TXT 举报
温馨提示
试读
3页
使用代码编写DataTemplate var template = new DataTemplate { VisualTree = rootfactory }; this.HeaderTemplate = template;
资源推荐
资源详情
资源评论
void OprColumn_Loaded(object sender, RoutedEventArgs e)
{
//新增
var rootfactory = new FrameworkElementFactory(typeof(StackPanel), "StPl");
rootfactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
var btnAddFactory = new FrameworkElementFactory(typeof(Button), "AddBtn");
btnAddFactory.SetResourceReference(FrameworkElement.StyleProperty, "AddButtonStyle");
//添加事件
btnAddFactory.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(OnAddClick));
btnAddFactory.SetValue(UIElement.VisibilityProperty, IsShowAdd);
//添加子元素
rootfactory.AppendChild(btnAddFactory);
//删除
btnAddFactory = new FrameworkElementFactory(typeof(Button), "delbutton");
//添加属性
//btnAddFactory.AppendChild(delImage);
btnAddFactory.SetResourceReference(FrameworkElement.StyleProperty, "DelButtonStyle");
btnAddFactory.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(OnDelClick));
btnAddFactory.SetValue(UIElement.VisibilityProperty, IsShowDel);
rootfactory.AppendChild(btnAddFactory);
//修改
btnAddFactory = new FrameworkElementFactory(typeof(Button), "EditBtn");
{
//新增
var rootfactory = new FrameworkElementFactory(typeof(StackPanel), "StPl");
rootfactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
var btnAddFactory = new FrameworkElementFactory(typeof(Button), "AddBtn");
btnAddFactory.SetResourceReference(FrameworkElement.StyleProperty, "AddButtonStyle");
//添加事件
btnAddFactory.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(OnAddClick));
btnAddFactory.SetValue(UIElement.VisibilityProperty, IsShowAdd);
//添加子元素
rootfactory.AppendChild(btnAddFactory);
//删除
btnAddFactory = new FrameworkElementFactory(typeof(Button), "delbutton");
//添加属性
//btnAddFactory.AppendChild(delImage);
btnAddFactory.SetResourceReference(FrameworkElement.StyleProperty, "DelButtonStyle");
btnAddFactory.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(OnDelClick));
btnAddFactory.SetValue(UIElement.VisibilityProperty, IsShowDel);
rootfactory.AppendChild(btnAddFactory);
//修改
btnAddFactory = new FrameworkElementFactory(typeof(Button), "EditBtn");
资源评论
tiigger
- 粉丝: 2
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功