WPF DataGrid 控件模板
我正在尝试自定义 WPF 4.0 DataGrid 并需要其控件模板的列表(也是嵌套 DataGridColumnHeadersPresenter - PART_ColumnHeadersPresenter 的控件模板)。我发现此链接提供了许多控件模板,但列表中缺少 DataGrid!是否有发布最新 WPF 4.0 DataGrid 的控件模板的地方。我尝试使用以下代码获取它,但它没有给我嵌套模板:
// 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());
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());
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个链接可以从 MSDN 上的控件样式和模板。您还可以使用 Reflector BamlViewer 插件直接读取主题来自大会。
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.