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? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -