任何人都有一个很好的示例,该示例如何深度克隆WPF对象并保留数据绑定?标记的答案是第一部分。第二部分是您必须创建一个ExpressionConverter并将其注入序列化过程。有关详细信息,请参见:http : //www.codeproject.com/KB/WPF/xamlwriterandbinding.aspx?fid= 1428301& df= 90& mpp=25&noise=3&sort= Position& view= Quick&select=2801571
3 回答
肥皂起泡泡
TA贡献1829条经验 获得超6个赞
在.NET 4.0中,新的xaml序列化堆栈使此MUCH更容易。
var sb = new StringBuilder();
var writer = XmlWriter.Create(sb, new XmlWriterSettings
{
Indent = true,
ConformanceLevel = ConformanceLevel.Fragment,
OmitXmlDeclaration = true,
NamespaceHandling = NamespaceHandling.OmitDuplicates,
});
var mgr = new XamlDesignerSerializationManager(writer);
// HERE BE MAGIC!!!
mgr.XamlWriterMode = XamlWriterMode.Expression;
// THERE WERE MAGIC!!!
System.Windows.Markup.XamlWriter.Save(this, mgr);
return sb.ToString();
添加回答
举报
0/150
提交
取消