WPF Binding : accessing subproperties of bound object -


i have control property named item of type x, item has property named tag of type y, , tag has other properties (caption, location,...).

i've written control template control, , need access tag's properties (caption, location,...etc) i've used binding relativesource templatedparent, , path i've tried use path=item.tag.caption follows :

 <controltemplate targettype="y:mycontrol">     <rectangle>         <rectangle.fill>            <solidcolorbrush                  color="{binding relativesource={relativesource templatedparent},                 path=item.tag.caption}" />         </rectangle.fill>     </rectangle> </controltemplate> 

but getting following error : tag property not found 'object' because data item null , getting no results.

the solution perform cast in path variable before accessing properties follows : path=item.(mynamespace:x.tag).(mynamespace:y.caption) more information check wpf binding : casting in binding path


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -