.net - How to center text in a specific column in WPF ListView? -


i tried , horizontalalignment, instead of textalignment still show aligned left.

<window x:class="editorwindow.mainwindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         datacontext="{binding relativesource={relativesource self}}"         title="mainwindow" height="800" width="600">     <grid>         <listview itemssource="{binding effects}">             <listview.view>                 <gridview>                     <gridviewcolumn width="100" header="name" displaymemberbinding="{binding name}"  />                     <gridviewcolumn width="100" header="type" >                         <gridviewcolumn.celltemplate >                             <datatemplate>                                 <textblock text="{binding type}" textalignment="center"/>                             </datatemplate>                         </gridviewcolumn.celltemplate>                     </gridviewcolumn>                     <gridviewcolumn width="100" header="opacity" displaymemberbinding="{binding opacity}" />                 </gridview>             </listview.view>         </listview>     </grid> </window> 

try set horizontalcontentalignment stretch itemcontainerstyle. should work either textalignment="center" or horizontalalignment="center" textblock

<listview itemssource="{binding effects}">     <listview.itemcontainerstyle>         <style targettype="listviewitem">             <setter property="horizontalcontentalignment" value="stretch"/>         </style>     </listview.itemcontainerstyle>     <!--...--> </listview> 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -