日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
C#實(shí)現(xiàn)ControlTemplate方法

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

藁城網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)公司,藁城網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為藁城近千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)營(yíng)銷網(wǎng)站建設(shè)要多少錢(qián),請(qǐng)找那個(gè)售后服務(wù)好的藁城做網(wǎng)站的公司定做!

現(xiàn)在主流的控件模板和樣式是引用XAML資源,不過(guò)感覺(jué)沒(méi)有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(這里為T(mén)extBox)  
  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)容封裝起來(lá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方法。


名稱欄目:C#實(shí)現(xiàn)ControlTemplate方法
本文來(lái)源:http://www.dlmjj.cn/article/dpjhoso.html