WPF Binding : Casting in binding path

后端 未结 1 1079
借酒劲吻你
借酒劲吻你 2020-12-04 14:47

I\'ve a binding where the Path is set to Path=Item.Tag.caption, but I need to cast Item to IEDGE first so I can access th

相关标签:
1条回答
  • 2020-12-04 15:15

    The solution for the problem, finally, is to use following syntax:

    Path=Item.(myNameSpace:IEdge.Tag).caption
    

    The previous code cast Item to the type IEdge in order to access the Tag property.

    In case of multiple nested casts the global pattern is :

    Path=Obj1.(ns1:TypeObj1.Obj2).(ns2:TypeObj2.Obj3)...(nsN:TypeObjN.BindedProp) 
    

    As suggested in comments Do not use shorthand binding syntax when using this solution. Ensure you actually use Path= otherwise it won't work!

    0 讨论(0)
提交回复
热议问题