views:

58

answers:

2

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?

A: 

You may be able to do something like the following (untested). If this is problematic I'd just create a new Binding and use BindingOperations.SetBinding.

Binding binding = BindingOperations.GetBinding(target, dp);
binding.Source = yourSource;

-- or --

BindingOperations.SetBinding(target, dp, binding);
Taylor Leese
A: 

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(); 
}
runrunraygun
i guess i just have to copy those properties manually then...
Aran Mulholland