WPF DataGrid控件模板 [英] WPF DataGrid Control Template

查看:673
本文介绍了WPF DataGrid控件模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试自定义WPF 4.0 DataGrid,并需要其控件模板(也是嵌套的DataGridColumnHeadersPresenter - PART_ColumnHeadersPresenter的控件模板)的列表。我发现链接提供了许多控件模板,但DataGrid从列表中缺少!是否有任何地方发布最新WPF 4.0 DataGrid的控制模板。我试图使用以下代码获取它,但它不给我嵌套模板:

  //创建一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆