WPF TabControl and DataTemplates -
i've got set of viewmodels i'm binding itemssource property of tabcontrol. let's call viewmodels aviewmodel, bviewmodel, , cviewmodel. each 1 of needs have different itemtemplate (for header; because each need show different icon) , different contenttemplate (because have different interaction models).
what i'd this:
defined in resource.xaml files somewhere:
<datatemplate x:key="itemtemplate" datatype="{x:type aviewmodel}"> ... </datatemplate> <datatemplate x:key="itemtemplate" datatype="{x:type bviewmodel}"> ... </datatemplate> <datatemplate x:key="itemtemplate" datatype="{x:type cviewmodel}"> ... </datatemplate> <datatemplate x:key="contenttemplate" datatype="{x:type aviewmodel}"> ... </datatemplate> <datatemplate x:key="contenttemplate" datatype="{x:type bviewmodel}"> ... </datatemplate> <datatemplate x:key="contenttemplate" datatype="{x:type cviewmodel}"> ... </datatemplate>
defined separately:
<tabcontrol itemtemplate="[ way select "itemtemplate" based on type ]" contenttemplate="[ way select "contenttemplate" based on type ]"/>
now, know realistically, each time define datatemplate same key system going complain. but, there can that's similar let me put datatemplate tabcontrol based on name , datatype?
one way use datatemplateselector
s , have each 1 resolve resource separate resourcedictionary
.
Comments
Post a Comment