silverlight - Item Template in the ItemPresenter -
in template itempresenter defines host panel items. possible define itemtemplate?
<controltemplate x:key="itemscontroltemplate" targettype="itemscontrol"> <grid> <grid.rowdefinitions> <rowdefinition height="*"/> </grid.rowdefinitions> <scrollviewer> <itemspresenter width="{templatebinding width}" height="{templatebinding height}"/> </scrollviewer> </grid> </controltemplate>
to go further, i've created class:
public class itemscontrolextended : itemscontrol { public itemscontrolextended() { defaultstylekey = typeof(itemscontrolextended); } }
and create dependency property "itemsmargin". after i've done i'm supposed bind item "margin" property "itemsmargin". how possible implement?
getcontainerforitemoverride ? preparecontainerforitemoverride ? onapplytemplate ?
you can't define itemtemplate controltemplate
control whole.
instead create style includes control template , the other templates required:-
<style x:key="itemscontrolstyle" targettype="itemscontrol> <setter property="template"> <setter.value> <controltemplate targettype="itemscontrol"> <!-- template above --> </controltemplate> </setter.value> </setter> <setter property="itemspanel"> <setter.value> <itemspaneltemplate> <!-- alternative stackpanel if desired --> </itemspaneltemplate> </setter.value> </setter> <setter property="itemtemplate"> <setter.value> <dataltemplate> <!-- item template wanted --> </datatemplate> </setter.value> </setter> </style>
now can style itemscontrol:-
<itemscontrol style="{staticresource itemscontrolstyle}">
Comments
Post a Comment