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