Binding does not have a Clone method, whats an effective way to copy it

前端 未结 4 1210
情歌与酒
情歌与酒 2020-12-11 03:03

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

4条回答
  •  猫巷女王i
    2020-12-11 03:46

    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(); 
    }
    

提交回复
热议问题