Quantcast
Viewing all articles
Browse latest Browse all 18858

Update Binding when Property A in Property B(Path of binding) in class C (source of binding) updates.

Good time of a day. 

I have class A and class B

class B have property PB

class A have property-wrapper PA for inner field of type B

so, i have class C, which i cannot change.

I've try to create Binding with Source - A and PropertyPath PA, the target is C. When i've changed PB(and so changed PA) Binding(and target, C) haven't updated.

Next, I've try to create Binding with Source A.PA and without PropertyPath (I guess, it's the same) - and Binding haven't updated.

When I've try to create new instance of B, copy fields from old instance and set PA to new instance, Binding have updated.

How I can "tell" to Binding that the source have updated? Or, maybe this have a better solution?

Some code here:

public class B
{
     string pB;
     public string PB;
     {get; set;}
}

public class A
{
     B pA;
     public B PA
     {get; set;}
}

//a is the instance of A
//creating binding
//c is the instance of class C
//i have thousands of instance of C in different collections

Binding bind1 = new Binding();
bind1.Source = A;
bind1.PropertyPath = PA;
bind1.Converter = new SomeConverter();
bind1.ConverterParameter = someConverterPararmeter;
BindingOperations.SetBinding(c, c.FillProperty, bind1);

Binding bind2 = new Binding();
bind2.Source = A.PA;
bind2.Converter = new SomeConverter();
bind2.ConverterParameter = someConverterPararmeter;
BindingOperations.SetBinding(c, c.FillProperty, bind2);

//now I change the property
A.PA.PB="somestring";
//and both bind1 and bind2 will not update

Thanks for looking.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>