WPF DataGrid Control Template

女生的网名这么多〃 提交于 2019-12-06 01:32:47

问题


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());

回答1:


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.



来源:https://stackoverflow.com/questions/3548503/wpf-datagrid-control-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!