绑定没有克隆方法,有什么有效的方法可以复制 [英] Binding does not have a Clone method, whats an effective way to copy it
本文介绍了绑定没有克隆方法,有什么有效的方法可以复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望复制一个绑定,这样我就可以在不影响原始绑定的情况下为其设置不同的源属性.这只是将新绑定上的所有属性设置为与旧绑定相同的情况吗?
I wish to copy a binding, this is so i can set a different source property on it without affecting the original binding. Is this just a case of setting all of the properties on the new binding to be the same as the old?
推荐答案
如果您无法找到执行此操作的方法,请为 Binding 创建一个扩展.
if you can't find a method to do this already create an exetension for Binding.
public static class BindingExtensions
{
public static Binding Clone(this Binding binding)
{
var cloned = new Binding();
//copy properties here
return cloned;
}
}
public void doWork()
{
Binding b= new Binding();
Binding nb = b.Clone();
}
这篇关于绑定没有克隆方法,有什么有效的方法可以复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文