xaml - ControlTemplate(Style) binding ItemsSource property -
i want data binding in style(controltemplate) in listview
my listview looks like:
<listview itemtemplateselector="{staticresource itemtemplate_selector}" itemcontainerstyleselector="{staticresource itemcontainerstyle_selector}"/>
most of properties fetched itemssource binding in datatemplate:
e.g.
<datatemplate x:key="oneofitem"> <grid> <grid.rowdefinitions> <rowdefinition height="30"/> <rowdefinition height="*"/> </grid.rowdefinitions> <textblock grid.row="0" text="{binding name}"/> <stackpanel grid.row="1"> <richtextblock grid.column="0" local:hyperlinkextensions.text="{binding message}"/> <textblock grid.column="1" text="{binding time}"/> </stackpanel> </grid> </datatemplate>
for reason there's area affected different visual state , there's property displayed in area, have binding in itemcontainerstyle like:
e.g.
<style x:key="headpicstyle" targettype="listviewitem"> <setter property="template"> <setter.value> <controltemplate targettype="listviewitem"> <border> <grid> <grid.columndefinitions> <columndefinition x:name="header" width="20"/> <columndefinition width="*"/> </grid.columndefinitions> <grid grid.column="0"> <textblock x:name="headertext" text="{binding header}"/> </grid> <contentpresenter grid.column="1" x:name="contentpresenter" contenttemplate="{templatebinding contenttemplate}" contenttransitions="{templatebinding contenttransitions}" horizontalalignment="{templatebinding horizontalcontentalignment}" margin="{templatebinding padding}" verticalalignment="{templatebinding verticalcontentalignment}"/> </grid> <visualstatemanager.visualstategroups> <visualstategroup x:name="adaptivestatestest"> <visualstate x:name="defaultstatetest"> <visualstate.statetriggers> <adaptivetrigger minwindowwidth="{staticresource widestatechangethreshold}" /> </visualstate.statetriggers> </visualstate> <visualstate x:name="narrowstatetest"> <visualstate.statetriggers> <adaptivetrigger minwindowwidth="{staticresource narrowstatewindowwidth}" /> </visualstate.statetriggers> <visualstate.setters> <setter target="header.width" value="100"/> </visualstate.setters> </visualstate> </visualstategroup> </visualstatemanager.visualstategroups> </border> </controltemplate> </setter.value> </setter>
on perspective, itemcontainerstyle targeted itemsource in listview, can access it's property (means can directly binding property name)
however, headertext's text can not seen in app.
i'm wondering if binding in style wrong or not?
Comments
Post a Comment