public void loadCheckListDataTemplate(TreeViewItem tvi)

{

DataTemplate cdt = new DataTemplate();

FrameworkElementFactory cfef = new FrameworkElementFactory(typeof(StackPanel));

cfef.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

Binding binding = new Binding();

FrameworkElementFactory subfef1 = new FrameworkElementFactory(typeof(TextBlock));

subfef1.SetValue(TextBlock.TextProperty, binding);

subfef1.SetValue(TextBlock.MarginProperty, new Thickness(0, 0, 5, 0));

cfef.AppendChild(subfef1);

FrameworkElementFactory subfef2 = new FrameworkElementFactory(typeof(CheckBox));

subfef2.SetValue(CheckBox.ContentProperty, "添加");

subfef2.SetValue(CheckBox.MarginProperty, new Thickness(0, 0, 5, 0));

cfef.AppendChild(subfef2);

FrameworkElementFactory subfef3 = new FrameworkElementFactory(typeof(CheckBox));

subfef3.SetValue(CheckBox.ContentProperty, "修改");

subfef3.SetValue(CheckBox.MarginProperty, new Thickness(0, 0, 5, 0));

cfef.AppendChild(subfef3);

FrameworkElementFactory subfef4 = new FrameworkElementFactory(typeof(CheckBox));

subfef4.SetValue(CheckBox.ContentProperty, "删除");

subfef4.SetValue(CheckBox.MarginProperty, new Thickness(0, 0, 5, 0));

cfef.AppendChild(subfef4);

cdt.VisualTree = cfef;

tvi.HeaderTemplate = cdt;

}

WPF后台生成datatemplate(TreeViewItem例子)的更多相关文章

  1. WPF 后台重写 DataTemplate

    /// <summary> /// 配置类 /// </summary> public static class GridControlDeploy { /// <sum ...

  2. WPF 后台获得 数据模板里的内容控件(DataTemplate)

    原文:WPF 后台获得 数据模板里的内容控件(DataTemplate) 假如      <Window.Resources> 里 有一个 Datatemplate 我想获得TextBlo ...

  3. C#生成随机验证码例子

    C#生成随机验证码例子: 前端: <tr> <td width=" align="center" valign="top"> ...

  4. WPF 动态创建 DataTemplate 及数据绑定

    WPF 动态创建 DataTemplate 及数据绑定 运行环境:Window7 64bit,.NetFramework4.61,C# 6.0: 编者:乌龙哈里 2017-02-22 参考: star ...

  5. WPF后台设置xaml控件的样式System.Windows.Style

    WPF后台设置xaml控件的样式System.Windows.Style 摘-自 :感谢 作者: IT小兵   http://3w.suchso.com/projecteac-tual/wpf-zhi ...

  6. WPF后台访问XAML元素

    当我们需要从后台访问xaml文件时,我们可以通过这样的方式来操作: private void button1_Click(object sender, RoutedEventArgs e) { Sys ...

  7. 后台生成EXCEL文档,自定义列

    后台生成EXCEL文档,自定义列 //response输出流处理 //设置编码.类型.文件名 getResponse().reset(); getResponse().setCharacterEnco ...

  8. [Spark][Python]Spark 访问 mysql , 生成 dataframe 的例子:

    [Spark][Python]Spark 访问 mysql , 生成 dataframe 的例子: mydf001=sqlContext.read.format("jdbc").o ...

  9. 后台生成excel前端下载

    后台生成Excel时前端获取下载 Controller控制器: package com.example.test.controller; import com.example.test.common. ...

随机推荐

  1. html5 Canvas和SVG的区别是什么(总结)

    html5 Canvas和SVG的区别是什么(总结) 一.总结 一句话总结:都是2D做图,svg是矢量图,canvas是位图.Canvas 是逐像素进行渲染的,适合游戏. 1.svg的全称是什么? S ...

  2. 复制相关参数学习笔记--slave上的参数

    server_id server_uuid   relay_log io_thread 读取过来的本地日志. relaylog文件名前缀,可以是全路径.   relay_log_index relay ...

  3. poj2151之概率DP

    Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4403   ...

  4. ZOJ 3209 Treasure Map DLX

    用最少的矩阵覆盖n*m的地图.注意矩阵不能互相覆盖. 这里显然是一个精确覆盖,但因为矩阵拼接过程中,有公共的边,这里须要的技巧就是把矩阵的左边和以下截去一个单位. #include <stdio ...

  5. Tricks(四十七)—— 布尔矩阵(0-1矩阵)取反

    假定 X 是一个 0-1 元素构成的布尔矩阵,则对其取反,0 变成 1,1 变为 0(True 变为 False,False 变成 True),只需要一步简单的操作: Y = (X == False)

  6. 商(quotient)—— 两数之比

    1. IQ:Intelligence quotient IQ=MACA×100 MA:心智年龄(mental age) CA:实足年龄(chronological age)

  7. Ubuntu 16.04安装MinGW32(在/etc/apt/sources.list里添加源)

    Ubuntu 16.04下直接使用命令安装MinGW32: sudo apt-get install mingw32   但是,会报错: Unable to locate package mingw3 ...

  8. 【43.75%】【codeforces 688E】The Values You Can Make

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  9. 【64.22%】【codefoces round 382A】Ostap and Grasshopper

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  10. numpy 辨异(四)—— np.repeat 与 np.tile

    >> import numpy as np >> help(np.repeat) >> help(np.tile) 二者执行的是均是复制操作: np.repeat: ...