silverlight 4.0 - DataTemplateSelector issue -
in silverlight project, needed use datatemplateselector
. found way implement (as it's not present in framework) here : http://www.codeproject.com/kb/silverlight/sltemplateselector.aspx
this method has been working correctly in other places of code, time doesn't work. problem templateselector never called (i tried put breakpoint in constructor, never hit). can see problem in code ? used debug converter, , see listbox
's itemssource
correctly set.
thanks in advance !
xaml:
<listbox name="destinationslist" grid.column="2" itemssource="{binding}"> <listbox.itemtemplate> <datatemplate> <helper:targettemplateselector content="{binding}"> <helper:targettemplateselector.firsttemplate> <datatemplate> <textblock text="test1" /> </datatemplate> </helper:targettemplateselector.firsttemplate> <helper:targettemplateselector.secondtemplate> <datatemplate> <textblock text="test2" /> </datatemplate> </helper:targettemplateselector.secondtemplate> </helper:targettemplateselector> </datatemplate> </listbox.itemtemplate> </listbox>
templateselector class:
public class targettemplateselector : datatemplateselector { public datatemplate firsttemplate { get; set; } public datatemplate secondtemplate { get; set; } public override datatemplate selecttemplate(object item, dependencyobject container) { myclass1 target = item myclass1; if (target != null) { if (target.profile myclass2) { return this.firsttemplate; } else if (target.profile myclass3) { return this.secondtemplate; } else { throw new notimplementedexception(); } } return base.selecttemplate(item, container); } }
so dumb... i'll take excuse it's friday...
the problem value bound listbox wasn't collection...
you may start throwing stones...
Comments
Post a Comment