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

WPF默認模板調用方法簡介

開發(fā) 開發(fā)工具
我們在文章中用一個代碼示例來為大家詳細介紹了WPF默認模板的調用相關技巧,方便大家了解,希望通過這篇文章的介紹能充分掌握這一知識。

WPF中具有一些模板,在學習的過程中我們需要熟練的掌握這些模板的應用。在這里我們先來了解一下WPF默認模板調用的具體方法。#t#

***的模板示例:我們知道每個控件都有自己默認的模板,這是MS編寫的,如果我們能夠得到這些模板的XAML代碼,那么它將是學習模板的***的示例,

要想獲得某個控件ctrl的默認模板,請調用以下方法:

 

  1. string GetTemplateXamlCode
    (Control ctrl) {  
  2. FrameworkTemplate template
     = ctrl.Template;   
  3. string xaml = "";   
  4. if (template != null) {   
  5. XmlWriterSettings settings =
     
    new XmlWriterSettings();  
  6. settings.Indent = true;   
  7. settings.IndentChars = 
    new string(' ', 4);  
  8. settings.NewLineOnAttributes = true;   
  9. StringBuilder strbuild = 
    new StringBuilder();   
  10. XmlWriter xmlwrite = 
    XmlWriter.Create(strbuild, 
    settings); 
  11. try { XamlWriter.Save(template,
     xmlwrite);  
  12. xaml = strbuild.ToString();   
  13. }   
  14. catch (Exception exc)   
  15. xaml = exc.Message;   
  16. }   
  17. }   
  18. else {   
  19. xaml = "no template";   
  20. }   
  21. return xaml;   
  22. }  

 

責任編輯:曹凱 來源: IT168
相關推薦

2009-12-23 18:06:25

WPF模板

2009-12-14 16:44:56

Ruby調用DLL

2010-01-06 17:06:05

Json格式

2010-02-01 10:04:25

Python模板函數(shù)

2009-12-24 14:08:25

WPF數(shù)據(jù)模板

2009-12-28 15:08:12

WPF字體

2009-12-25 10:05:06

WPF資源

2009-12-25 14:35:34

WPF布局

2009-12-28 15:48:14

WPF窗口顏色

2009-12-24 14:18:57

WPF類型轉換

2009-12-24 16:36:06

WPF InkCanv

2009-12-28 09:24:58

WPF線程

2010-04-07 15:47:32

Oracle 11g

2009-12-28 10:40:13

WPF調用Winfor

2009-12-28 16:00:36

WPF樣式繼承

2009-12-24 18:09:23

WPF開發(fā)環(huán)境

2009-12-28 17:33:19

WPF視頻音頻

2009-12-24 17:57:53

WPF頁面跳轉

2009-12-28 11:14:29

WPF顯示文本

2009-12-24 13:31:25

WPF UI設計
點贊
收藏

51CTO技術棧公眾號