Chinaunix首页 | 论坛 | 博客
  • 博客访问: 579289
  • 博文数量: 718
  • 博客积分: 4000
  • 博客等级: 上校
  • 技术积分: 4960
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-17 13:24
文章分类

全部博文(718)

文章存档

2011年(1)

2008年(717)

我的朋友

分类:

2008-10-17 13:36:11

以下是引用片段:
//控件呈现的显示内容1(这里为Image) 
FrameworkElementFactory fe = new FrameworkElementFactory(typeof(Image), "Image"); 
BitmapImage bi = new BitmapImage(); 
bi.BeginInit(); 
bi.UriSource = new Uri(@"E:ChartControlHanYangChartControlImageMainBackground.jpg"); 
bi.EndInit(); 
fe.SetValue(Image.SourceProperty, bi); 
//控件呈现的显示内容2(这里为TextBox) 
FrameworkElementFactory fe2 = new FrameworkElementFactory(typeof(TextBox), "TextBox"); 
fe2.SetValue(TextBox.WidthProperty,100.0); 
fe2.SetValue(TextBox.HeightProperty, 100.0); 
//把要呈现的显示内容封装起来 
FrameworkElementFactory f = new FrameworkElementFactory(typeof(Grid), "Grid"); 
f.AppendChild(fe); 
f.AppendChild(fe2); 
//控件模板 
ControlTemplate ct = new ControlTemplate(typeof(Button)); 
ct.VisualTree = f; 
//修改Button 的Template 
Button btn = new Button(); 
btn.Template = ct;
--------------------next---------------------

阅读(295) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~