WPF XElement

冏程序 2014-12-25 11:24:55
XElement xDataTemplate = new XElement(ns + "DataTemplate",
new XAttribute("xmlns:x", "http://schemas.microsoft.com/winfx/2006/xaml"),
new XAttribute("xmlns:mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"),
new XAttribute("xmlns:d", "http://schemas.microsoft.com/expression/blend/2008"),
new XElement(ns+"TextBlock", new XAttribute("Text", "{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGridRow}}, Path=Header}")));
主要是花横线的地方,需要引用http://schemas.microsoft.com/winfx/2006/xaml这个命名空间。请高手指点下,这句代码怎么写才对?
...全文
168 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
exception92 2014-12-25
  • 打赏
  • 举报
回复
你想完成 怎样的功能? 这段代码 写在了后台?
exception92 2014-12-25
  • 打赏
  • 举报
回复
引用 6 楼 ht_zhaoliubin 的回复:
我这边是日文系统,所以我不认识没法拷贝出来查。
那这 怎么猜呀!! ns 有声明没
冏程序 2014-12-25
  • 打赏
  • 举报
回复
我这边是日文系统,所以我不认识没法拷贝出来查。
exception92 2014-12-25
  • 打赏
  • 举报
回复
引用 4 楼 ht_zhaoliubin 的回复:
XElement xDataTemplate = new XElement(ns + "DataTemplate", new XAttribute("xmlns:x", "http://schemas.microsoft.com/winfx/2006/xaml")); 大哥这句代码肯本就运行不过去啊
什么错呀?
冏程序 2014-12-25
  • 打赏
  • 举报
回复
XElement xDataTemplate = new XElement(ns + "DataTemplate",
new XAttribute("xmlns:x", "http://schemas.microsoft.com/winfx/2006/xaml"));
大哥这句代码肯本就运行不过去啊
exception92 2014-12-25
  • 打赏
  • 举报
回复
引用 2 楼 ht_zhaoliubin 的回复:
是的,想通过后台C#代码实现生成一个数据模板。
生成数据模板的话, new XAttribute("xmlns:x", "http://schemas.microsoft.com/winfx/2006/xaml"), 这句不是应经引用了么, 都可以把 x:Type 给去掉了。
冏程序 2014-12-25
  • 打赏
  • 举报
回复
是的,想通过后台C#代码实现生成一个数据模板。

8,735

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧