c# - How to specify that a combobox use a specific ComboBoxItem Template -
i have wpf comboboxitem template works fine. want applied specific comboboxes way of specific combobox style. don't know in combobox style should point combobox item style. suggestions
<style targettype="comboboxitem"> <setter property="snapstodevicepixels" value="true"/> <setter property="overridesdefaultstyle" value="true"/> <setter property="horizontalcontentalignment" value="left" /> <setter property="verticalcontentalignment" value="center" /> <setter property="template"> <setter.value> <controltemplate targettype="comboboxitem"> <border name="border" padding="2" snapstodevicepixels="true" borderthickness="1"> <contentpresenter /> </border> <controltemplate.triggers> ... </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style>
<style x:key="s" targettype="comboboxitem"> ... </style> <combobox x:name="comboboxwithoutitemstyle"/> <combobox x:name="comboboxwithitemstyle" itemcontainerstyle="{staticresource s}"/>
update based on comment: or, part of style:
<style x:key="s2" targettype="combobox"> <setter property="itemtemplate" value="{staticresource s}"/> </style>
Comments
Post a Comment