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
Post a Comment