WPF Binding : Casting in binding path

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 the Tag Property. Is there a way to achieve this?


Solution 1:

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!