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. ...
随机推荐
- [Docker] Create a Volume
We can create volumn to keep the data, even we stop the container and restart again, the data won't ...
- 【u006】海战
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 在峰会期间,武装部队得处于高度戒备.警察将监视每一条大街,军队将保卫建筑物,领空将布满了F-2003飞 ...
- [Vue] Use Vue.js Watchers to Respond to Async Updates
Use watchers to keep an eye on your data. Watchers are methods that are invoked when the specified a ...
- 基于 Android NDK 的学习之旅-----Android.mk 介绍
一个Android.mk file用来向编译系统描述你的源代码.具体来说:该文件是GNU Makefile的一小部分,会被编译系统解析一次或多次.你可以在每一个Android.mk file中定义一个 ...
- Java多线程编程— 概念以及经常使用控制
多线程能满足程序猿编写很有效率的程序来达到充分利用CPU的目的,由于CPU的空暇时间可以保持在最低限度.有效利用多线程的关键是理解程序是并发运行而不是串行运行的.比如:程序中有两个子系统须要并发运行, ...
- 关于Boolean类型做为同步锁异常问题
public class Test2 { private static volatile Boolean aBoolean = true; static class A implements Runn ...
- 再续FPGA初心,京微齐力脱胎京微雅格重新起航(700万元天使轮,泰有基金领投,水木基金、臻云创投、泰科源跟投。数千万元Pre-A轮融资,领投方为海康基金)
集微网消息,新的一年开启新的希望,新的空白承载新的梦想.这是年初一集微网给读者们拜年时写的寄语.在中国农历新年开年之际,半导体产业里也迎来了许多新的起点.例如长江存储在与苹果就采购前者的Nand闪存芯 ...
- 【物理】概念的理解 —— Phase(相位)
Phase is the position of a point in time (an instant) on a waveform cycle. 相位指的是波形周期中点在某一时刻的位置.Phase ...
- ANR问题分析实例
ANR监测机制包含三种: Service ANR,前台进程中Service生命周期不能超过20秒,后台进程中Service的生命周期不能超过200秒. 在启动Service时,抛出定时消息SERVIC ...
- MySQL实现类似Oracle中的nextval和currval
CREATE TABLE `sequence` ( `seq_name` varchar(50) NOT NULL, `current_val` int(11) NOT NULL, `incremen ...