WPF后台生成datatemplate(TreeViewItem例子)
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例子)的更多相关文章
- WPF 后台重写 DataTemplate
/// <summary> /// 配置类 /// </summary> public static class GridControlDeploy { /// <sum ...
- WPF 后台获得 数据模板里的内容控件(DataTemplate)
原文:WPF 后台获得 数据模板里的内容控件(DataTemplate) 假如 <Window.Resources> 里 有一个 Datatemplate 我想获得TextBlo ...
- C#生成随机验证码例子
C#生成随机验证码例子: 前端: <tr> <td width=" align="center" valign="top"> ...
- WPF 动态创建 DataTemplate 及数据绑定
WPF 动态创建 DataTemplate 及数据绑定 运行环境:Window7 64bit,.NetFramework4.61,C# 6.0: 编者:乌龙哈里 2017-02-22 参考: star ...
- WPF后台设置xaml控件的样式System.Windows.Style
WPF后台设置xaml控件的样式System.Windows.Style 摘-自 :感谢 作者: IT小兵 http://3w.suchso.com/projecteac-tual/wpf-zhi ...
- WPF后台访问XAML元素
当我们需要从后台访问xaml文件时,我们可以通过这样的方式来操作: private void button1_Click(object sender, RoutedEventArgs e) { Sys ...
- 后台生成EXCEL文档,自定义列
后台生成EXCEL文档,自定义列 //response输出流处理 //设置编码.类型.文件名 getResponse().reset(); getResponse().setCharacterEnco ...
- [Spark][Python]Spark 访问 mysql , 生成 dataframe 的例子:
[Spark][Python]Spark 访问 mysql , 生成 dataframe 的例子: mydf001=sqlContext.read.format("jdbc").o ...
- 后台生成excel前端下载
后台生成Excel时前端获取下载 Controller控制器: package com.example.test.controller; import com.example.test.common. ...
随机推荐
- [JS Compose] 6. Semigroup examples
Let's we want to combine two account accidently have the same name. , friends: ['Franklin'] } , frie ...
- Java 常用工具类---- 各种字符集编码判断与转换
import java.io.UnsupportedEncodingException; /** * 判断字符编码 * * @author guyinyihun */ public class Cha ...
- [tmux] Enable mouse mode in tmux
We'll learn how to use mouse mode in tmux, including enable mouse control for resizing, scrolling an ...
- Qt 打开安卓相冊选择图片并获取图片的本地路径
Qt 打开安卓相冊选择图片并获取图片的本地路径 过程例如以下: 通过 Intent 打开安卓的系统相冊. 推荐使用 QAndroidJniObject::getStaticObjectField 获取 ...
- 前端Js框架汇总(工具多看)
前端Js框架汇总(工具多看) 一.总结 一句话总结: 二.前端Js框架汇总 概述: 有些日子没有正襟危坐写博客了,互联网飞速发展的时代,技术更新迭代的速度也在加快.看着Java.Js.Swift在各领 ...
- PatentTips - Heterogeneous Parallel Primitives Programming Model
BACKGROUND 1. Field of the Invention The present invention relates generally to a programming model ...
- Java冒泡排序与直接选择排序代码随笔
冒泡排序:延申的有很多种,有的是先确定最大值放到后面,有的是先确定最小值放到前边,还有就是反过来,先确定最小值的位置,但是本质都是:不断两两比较,交换位置...第一趟确定一个最大(最小)值放到前边(后 ...
- selenium 爬取空间说说
package cn.hb.util; import java.io.File; import java.io.FileWriter; import java.io.IOException; impo ...
- QSettings提供了非常方便的注册表读写
Qt的QSettings提供了非常方便的注册表读写 写入: //写入注册表 void setRegValue( QString strPath, QString strItemName, QStrin ...
- 英文构词法 —— ant、ent 后缀
1. -ant:--人 accountant:会计, account(ac+count):计数,账户: assistant:助手: assist:帮助 descendant:后裔: descend:下 ...