c# - How to bind to property of object returned by converter -
i'm trying bind value, run converter on it, , display property of value. having converter directly return property want wouldn't work, need property changes tracked.
what i'm trying achieve this:
// note: following not supported wpf // 'binding' cannot set on 'source' property of type 'binding'. // 'binding' can set on dependencyproperty of dependencyobject. text={binding textfield source={binding somevalue, converter={staticresource getobjectfromvalueconverter}}}` ideally, wrapped in simple markup extension.
text={l:gettextfield somevalue}
problem is, haven't been able find way other bind tag of element converter, , bind target field property follows:
tag={binding somevalue, converter={staticresource getobjectfromvalueconverter}} text={binding tag.textfield, relativesource={relativesource self}} this cumbersome, limited (you 1 tag field) , feels abusive. how else can go achieving want whilst monitoring changes of textfield though?
you can bind datacontext of textbox, instead of tag. make other bindings simpler:
datacontext="{binding somevalue, converter={staticresource getobjectfromvalueconverter}}" text="{binding textfield}" this assumes not have other bindings on textbox require inherited datacontext. example, in bindings below text2 broken:
datacontext="{binding somevalue, converter={staticresource getobjectfromvalueconverter}}" text2="{binding someothervalue, converter={staticresource getobjectfromvalueconverter}}" text="{binding textfield}" also, if have more complex control other textbox, datacontext controls below in logical/visual tree affected.
Comments
Post a Comment