Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Binding : Casting in binding path

Tags:

binding

wpf

xaml

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?

like image 904
Aminouvic Avatar asked May 15 '13 08:05

Aminouvic


1 Answers

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!

like image 63
Aminouvic Avatar answered Oct 11 '22 14:10

Aminouvic