silverlight - Caliburn.Micro convention for Accordion and AccordionItem -
i'd use caliburn.micro conventions accordion control silverlight , wpf toolkits:
view:
<grid background="white"> <controls:accordion x:name="items"/> </grid>
viewmodel:
public class shellviewmodel : ishell { public shellviewmodel() { items = new list<accitemviewmodel> { new accitemviewmodel { displayname = "header one", content = "content one" }, new accitemviewmodel { displayname = "header two", content = "content two" }, }; } public ienumerable<iscreen> items { get; set; } public class accitemviewmodel : screen { public string content { get; set; } }
by default, caliburn binds elements in accordion's itemssource accordionitem headers:
have added convention accordion's contenttemplate:
private void addcustomconventions() { conventionmanager.addelementconvention<accordion> (accordion.itemssourceproperty, "selecteditem", "selectionchanged") .applybinding = (viewmodeltype, path, property, element, convention) => { if (conventionmanager .getelementconvention(typeof(itemscontrol)) .applybinding(viewmodeltype, path, property, element, convention)) { element.setvalue(accordion.contenttemplateproperty, conventionmanager.defaultitemtemplate); return true; } return false; }; }
which achieved following:
but i'd either bind accordionitem's header displayname of accitemviewmodel(iscreen) or have header view model property on accitemviewmodel. accordionitem has headerproperty , headertemplateproperty, can't figure out how apply conventions these.
have @ wpf tabcontrol convention under source. should put on right path.
Comments
Post a Comment