结合不具有克隆方法,什么复制它的有效方法 [英] Binding does not have a Clone method, whats an effective way to copy it

查看:147
本文介绍了结合不具有克隆方法,什么复制它的有效方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要复制一个绑定,这是这样我就可以设置一个不同的源属性,而不会影响原有的绑定。这只是设置所有的新绑定的属性是一样的了?

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?

推荐答案

如果你的情况找不到要做到这一点已经创建绑定exetension的方法。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆