wpf - Get result of a Binding in code -


i'm searching wrong way, but:

is there way resulting value of binding through code?

probably glaring obvious, can't find it.

you need call providevalue method of binding. hard part need pass valid iserviceprovider method... edit: actually, that's not true... providevalue returns bindingexpression, not value of bound property.

you can use following trick:

class dummydo : dependencyobject {     public object value     {         { return (object)getvalue(valueproperty); }         set { setvalue(valueproperty, value); }     }      public static readonly dependencyproperty valueproperty =         dependencyproperty.register("value", typeof(object), typeof(dummydo), new uipropertymetadata(null));  }  public object evalbinding(binding b) {     dummydo d = new dummydo();     bindingoperations.setbinding(d, dummydo.valueproperty, b);     return d.value; }  ...  binding b = new binding("foo.bar.baz") { source = datacontext }; object value = evalbinding(b); 

not elegant, works...


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -