新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
WPF默認(rèn)模板調(diào)用方法簡(jiǎn)介
WPF中具有一些模板,在學(xué)習(xí)的過程中我們需要熟練的掌握這些模板的應(yīng)用。在這里我們先來(lái)了解一下WPF默認(rèn)模板調(diào)用的具體方法。#t#

創(chuàng)新互聯(lián)公司是一家專注于做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)與策劃設(shè)計(jì),豐鎮(zhèn)網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)10余年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:豐鎮(zhèn)等地區(qū)。豐鎮(zhèn)做網(wǎng)站價(jià)格咨詢:18980820575
***的模板示例:我們知道每個(gè)控件都有自己默認(rèn)的模板,這是MS編寫的,如果我們能夠得到這些模板的XAML代碼,那么它將是學(xué)習(xí)模板的***的示例,
要想獲得某個(gè)控件ctrl的默認(rèn)模板,請(qǐng)調(diào)用以下方法:
- string GetTemplateXamlCode
(Control ctrl) {- FrameworkTemplate template
= ctrl.Template;- string xaml = "";
- if (template != null) {
- XmlWriterSettings settings =
new XmlWriterSettings();- settings.Indent = true;
- settings.IndentChars =
new string(' ', 4);- settings.NewLineOnAttributes = true;
- StringBuilder strbuild =
new StringBuilder();- XmlWriter xmlwrite =
XmlWriter.Create(strbuild,
settings);- try { XamlWriter.Save(template,
xmlwrite);- xaml = strbuild.ToString();
- }
- catch (Exception exc)
- { xaml = exc.Message;
- }
- }
- else {
- xaml = "no template";
- }
- return xaml;
- }
網(wǎng)站題目:WPF默認(rèn)模板調(diào)用方法簡(jiǎn)介
網(wǎng)頁(yè)網(wǎng)址:http://m.fisionsoft.com.cn/article/coiegoh.html


咨詢
建站咨詢
