WPF pass parent binding object to the converter -


i have itemscontrol bound collection of type student. inside itemtemplate have textbox uses ivalueconverter custom calculations , logic. want pass actual student object value converter, instead property of it. how can that? here's sample of code.

 <itemscontrol itemssource="{binding studentlist}">                             <itemscontrol.itemtemplate>                                 <datatemplate>                                     <textblock text="{binding name}" />                                     <textblock text="{binding ????, converter={staticresource myconverter}}" />                                 </datatemplate>                             </itemscontrol.itemtemplate>  </itemscontrol> 

in code have this

public class myvalueconverter : ivalueconverter {       public object convert(object value, type targettype, object parameter, system.globalization.cultureinfo culture)         {             // want 'value' of type student.             return null;         } }  

you can leave out path. way @ actual object bound to.

<textblock text="{binding converter={staticresource myconverter}}"/> 

or if want explicit it:

<textblock text="{binding path=., converter={staticresource myconverter}}"/> 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -