自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

C#實(shí)現(xiàn)ControlTemplate方法

開發(fā) 后端
這里介紹C#實(shí)現(xiàn)ControlTemplate方法,現(xiàn)在主流的控件模板和樣式是引用XAML資源,不過感覺沒有C#代碼實(shí)現(xiàn)那么靈活。

C#實(shí)現(xiàn)ControlTemplate方法

現(xiàn)在主流的控件模板和樣式是引用XAML資源,不過感覺沒有C#代碼實(shí)現(xiàn)那么靈活,介紹一下C#實(shí)現(xiàn)ControlTemplate方法:

  1. //控件呈現(xiàn)的顯示內(nèi)容1(這里為Image)  
  2. FrameworkElementFactoryfe=newFrameworkElementFactory(typeof(Image),"Image");  
  3.  
  4. BitmapImagebi=newBitmapImage();  
  5. bi.BeginInit();  
  6. bi.UriSource=newUri(@"E:ChartControlHanYangChartControlImageMainBackground.jpg");  
  7. bi.EndInit();  
  8.  
  9. fe.SetValue(Image.SourceProperty,bi);  
  10.  
  11. //控件呈現(xiàn)的顯示內(nèi)容2(這里為TextBox)  
  12. FrameworkElementFactoryfe2=newFrameworkElementFactory(typeof(TextBox),"TextBox");  
  13. fe2.SetValue(TextBox.WidthProperty,100.0);  
  14. fe2.SetValue(TextBox.HeightProperty,100.0);  
  15.  
  16. //把要呈現(xiàn)的顯示內(nèi)容封裝起來  
  17. FrameworkElementFactoryf=newFrameworkElementFactory(typeof(Grid),"Grid");  
  18. f.AppendChild(fe);  
  19. f.AppendChild(fe2);  
  20.  
  21. //控件模板  
  22. ControlTemplatect=newControlTemplate(typeof(Button));  
  23. ct.VisualTree=f;  
  24.  
  25. //修改Button的Template  
  26. Buttonbtn=newButton();  
  27. btn.Template=ct

以上介紹C#實(shí)現(xiàn)ControlTemplate方法。

【編輯推薦】

  1. 淺談C#開發(fā)WinForm
  2. Visual C#使用COM組件
  3. C#做Screen Capture程序
  4. 在C#中聲明API函數(shù)
  5. 描述C#開發(fā)WinForm
責(zé)任編輯:佚名 來源: 博客園
相關(guān)推薦

2010-01-22 13:45:36

C++代碼

2009-08-19 17:00:07

C#實(shí)現(xiàn)PrintPa

2009-09-11 11:39:23

C# RadioBut

2009-09-07 09:36:29

C# DisposeDispose方法

2009-04-20 10:09:46

C#優(yōu)先隊(duì)列.NET Framew

2009-09-02 18:53:28

C#鼠標(biāo)坐標(biāo)

2009-08-25 14:26:28

C#播放AVI文件

2009-09-10 17:37:01

C# get post

2009-09-10 18:06:25

C# button快捷

2024-05-16 12:33:37

C#編程指針

2009-08-26 18:11:52

前臺與后臺方法互調(diào)

2009-08-17 17:40:53

C# GetAllCu

2009-08-26 09:50:08

C# GreetPeo

2009-08-26 17:16:22

C# CheckSta

2009-09-11 09:59:47

2009-08-25 17:07:27

C#虛擬方法

2009-09-07 10:37:32

C#執(zhí)行Finaliz

2009-08-31 18:05:14

C#調(diào)用WalkTre

2009-08-19 14:42:21

C#重載LoadPos

2009-08-31 16:33:28

C#調(diào)用Dispose
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號