wpf - How to make both ListViewItem's template style and ListView.ItemTemplate working? -


i have code below in app.xaml. override template make background stays same transparent when click/hover on listviewitem.

    <style targettype="{x:type listviewitem}">          <setter property="background" value="transparent" />         <setter property="height" value="{staticresource rowheight}"/>          <setter property="template">             <setter.value>                 <controltemplate targettype="{x:type listviewitem}">                     <border                      borderbrush="transparent"                      borderthickness="0"                      background="{templatebinding background}">                         <gridviewrowpresenter horizontalalignment="stretch" verticalalignment="{templatebinding verticalcontentalignment}" width="auto" margin="0" content="{templatebinding content}"/>                     </border>                 </controltemplate>             </setter.value>         </setter>      </style> 

and asked question yesterday how add underlying progressbar across 2 or more listviewitem in wpf? wrote below , works if didn't apply style above. if so, see nothing in listview.

        <listview.itemtemplate>             <datatemplate>                 <grid>                     <grid.columndefinitions>                         <columndefinition/>                         <columndefinition/>                     </grid.columndefinitions>                     <progressbar grid.columnspan="2" grid.zindex="0" value="{binding progressbarvalue}"/>                     <label grid.column="0" grid.zindex="1" content="{binding ccc}"/>                     <label grid.column="1" grid.zindex="1" content="{binding ddd}"/>                 </grid>             </datatemplate>         </listview.itemtemplate>  

i need make background transparent why won't these codes work together? how can improve?

in addition, how guys know what's wrong here? have no idea can find reference/explanations or study mechanism behind xaml code..

try this:

<listview.itemcontainerstyle>                 <style targettype="{x:type listviewitem}">                     <setter property="template">                         <setter.value>                             <controltemplate targettype="{x:type listviewitem}">                                 <border                                      borderbrush="transparent"`enter code here`                                      borderthickness="0"                                      background="{templatebinding background}">                                     <gridviewrowpresenter horizontalalignment="stretch" verticalalignment="{templatebinding verticalcontentalignment}" width="auto" margin="0" content="{templatebinding content}"/>                                 </border>                             </controltemplate>                         </setter.value>                     </setter>                 </style>             </listview.itemcontainerstyle>         <listview.itemtemplate>             <datatemplate>                     <grid background="red">                         <grid.columndefinitions>                             <columndefinition/>                             <columndefinition/>                         </grid.columndefinitions>                         <progressbar grid.columnspan="2" grid.zindex="0" value="30"/>                         <label grid.column="0" grid.zindex="1" content="{binding}"/>                         <label grid.column="1" grid.zindex="1" text="{binding}"/>                     </grid>                 </datatemplate>         </listview.itemtemplate> 

and using book wpf 4.5 unleashed reference xaml.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -