wpf - Different template on different ListBoxItem value without DataTemplateSelector? -



wpf - Different template on different ListBoxItem value without DataTemplateSelector? -

as title, possible?

i have seen in treeview can defines different hierarchicaldatatemplate different datatype using datatype attribute, doens't need datatemplateselector.

so wonder if possible take template according binded value without using datatemplateselector?

in condition, simple, if info object's property = 1, display template1, 2 template2.

is possible without datatemplateselector?

yes, can utilize datatrigger

<style targettype="{x:type listboxitem}"> <setter property="template" value="{staticresource defaulttemplate}" /> <style.triggers> <datatrigger binding="{binding someproperty}" value="2"> <setter property="template" value="{staticresource template2}" /> </datatrigger> </style.triggers> </style>

i prefer datatriggers datatemplateselector because respond propertychange notifications, , prefer see ui logic in ui code.

wpf silverlight templates

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -