wpf - Hierarchy of applying multiple DataTemplates to a single DataType -


i've seen allusions question around so, haven't found specific answer yet.

say have models, objecta , objectb, inherit baseobject , have corresponding viewmodels, objectaviewmodel , objectbviewmodel. each datatype of datatemplate stored in resourcedictionary represents how typically displayed in view.

however, in circumstances, based on view's design, want use different datatemplate objecta stored in resourcedictionary, still use same datatemplate objectb. situation order of resource dictionaries matters?

i in process of refactoring old project wpf, , day or 2 away structuring part of program. so, i'll come answer on own in couple days, in case catches sooner, figured wasn't 1 wondering this. follows structure have in head how work.

class baseobject { }  class objecta : baseobject { } class objectb : baseobject { }  class baseobjectcollection : icollection<baseobject> { objecta; objectb; }  class objectaviewmodel { } class objectbviewmodel { }  <!-- main resources file --> <resourcedictionary>     <datatemplate datatype="{x:type objectaviewmodel}" />     <datatemplate datatype="{x:type objectbviewmodel}" /> </resourcedictionary>  <!-- displays objecta, objectb using above main resource file datatemplates --> <window x:name="viewa">     <window.resources>         <...code grabbing main resources file... />     </window.resources>      <itemscontrol itemssource="_baseobjectcollection" /> </window>  <!-- second resource file --> <resourcedictionary>     <datatemplate datatype="{x:type objectaviewmodel}" /> </resourcedictionary>  <!-- happens here? --> <window x:name="viewb">     <window.resources>         <...code grabbing main resource file... />         <...code grabbing second resource file... />     </window.resources>      <itemscontrol itemssource="_baseobjectcollection" /> </window> 

yes, use x:key's , templateselector, prefer use automatic selection process.

thanks.


Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -