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. pycharm Zooming in the Editor

    https://www.jetbrains.com/help/pycharm/zooming-in-the-editor.html To enable changing font size in th ...

  2. MD5工具类--可以直接拿来用不抛异常的MD5Util

    public class MD5Util { private static String byteArrayToHexString(byte b[]) { StringBuffer resultSb ...

  3. [Postgres] Group and Aggregate Data in Postgres

    How can we see a histogram of movies on IMDB with a particular rating? Or how much movies grossed at ...

  4. ITFriend创业败局(四):菜鸟CEO的自我修养

    自创业自封CEO以来,短短3个月,又经历了无数的磨练,快速成长中. 创业不同于打工,他要求你必须有全局观和综合能力,技术.市场.商务,啥都得会,还要处理各种各样的问题和矛盾. 根据个人经历,我总结了以 ...

  5. js中 慎用for(var o in arrays) 遍历数组,for(var i,i< objects.length;i++)与for(var i,n = objects.length;i<n;i++) 的性能区别

    原文:js中 慎用for(var o in arrays) 遍历数组,for(var i,i< objects.length;i++)与for(var i,n = objects.length; ...

  6. 毕设一:python 爬取苏宁的商品评论

    毕设需要大量的商品评论,网上找的数据比较旧了,自己动手 代理池用的proxypool,github:https://github.com/jhao104/proxy_pool ua:fake_user ...

  7. Python 工具类与工具函数 —— pair

    def pair(lis): n = len(lis) for i in range(n): for j in range(i+1, n): yield lis[i], lis[j] 这样在调用端,访 ...

  8. 符号函数(sign function)性质及应用

    sgn(x):=⎧⎩⎨−101if x<0,if x=0,if x>0. 形式及描述较为简单的数学对象,更应当注意的便是其细节问题,对于 sign 函数(符号函数),便是自变量取值为 0 ...

  9. nodebb中文社区

    V2MM —— 自由职业者社区 https://v2mm.tech/ 萌梦社区 https://qtdream.com/ React Native 中文社区 http://bbs.reactnativ ...

  10. MyEclipse各种版本号注冊码

    一:MyEclipse_6.0.1GA_E3.3.1_FullStackInstaller注冊码 Subscriber:javp Subscription Code:wLR7ZL-655551-685 ...