WPF DataGrid控件模板 [英] WPF DataGrid Control Template
问题描述
//创建一个XmlWriter
StringBuilder sb = new StringBuilder();
XmlWriterSettings xmlSettings = new XmlWriterSettings
{Indent = true,IndentChars =,NewLineOnAttributes = true};
XmlWriter writer = XmlWriter.Create(sb,xmlSettings);
//编写控件模板
ControlTemplate template = controlToExtract.Template;
XamlWriter.Save(template,writer);
//将结果写入显示
controlTemplate.AppendText(sb.ToString());
有一个链接可以下载默认WPF主题从控制样式和模板在MSDN上。您还可以使用 Reflector BamlViewer加载项直接阅读主题从组装。
I am trying to customize the WPF 4.0 DataGrid and need a listing of its control template (also the control template for the nested DataGridColumnHeadersPresenter - PART_ColumnHeadersPresenter). I found this link with provides many control templates, but DataGrid is missing from the list! Is there any place where the control template for the latest WPF 4.0 DataGrid is published. I tried to get it using the following code, but it does not give me nested templates:
// Create an XmlWriter
StringBuilder sb = new StringBuilder();
XmlWriterSettings xmlSettings = new XmlWriterSettings
{ Indent = true, IndentChars = " ", NewLineOnAttributes = true };
XmlWriter writer = XmlWriter.Create(sb, xmlSettings);
// Write the control template
ControlTemplate template = controlToExtract.Template;
XamlWriter.Save(template, writer);
// Write results to display
controlTemplate.AppendText(sb.ToString());
There is a link to download the Default WPF Themes from Control Styles and Templates on MSDN. You can also use the Reflector BamlViewer add-in to read the themes directly from the assemblies.
这篇关于WPF DataGrid控件模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!