我如何将TextBlock是右对齐
< GridViewColumn WIDTH =45>
< GridViewColumnHeader CONTENT =#督HorizontalContentAlignment =左/>
< GridViewColumn.CellTemplate>
<的DataTemplate>
< TextBlock的TextWrapping =NoWrap的TextAlignment =右的HorizontalAlignment =右
文本={绑定路径=伯爵的StringFormat = {} {0:N0},模式=单向}/>
< / DataTemplate中>
< /GridViewColumn.CellTemplate>
< / GridViewColumn>
HorizontalContentAlignment和TextAlignment不解决它(对我来说)
甚至尝试,并没有解决它(对我来说)
< ListView.Resources>
<风格的TargetType =ListViewItem的>
< setter属性=HorizontalContentAlignmentVALUE =右/>
< /样式和GT;
< /ListView.Resources>
解决方案
有一个看看这里:
的http://highfieldtales.word$p$pss.com/2013/11/10/hacking-the-wpf-gridview-two-more-features/
这是一个系列的职位按我如何破解GridView控件,并得到一些隐藏的宝石从它。
How do I get the TextBlock to be Right aligned
<GridViewColumn Width="45">
<GridViewColumnHeader Content="#Doc" HorizontalContentAlignment="Left"/>
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="NoWrap" TextAlignment="Right" HorizontalAlignment="Right"
Text="{Binding Path=Count, StringFormat={}{0:N0}, Mode=OneWay}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
HorizontalContentAlignment and TextAlignment don't fix it (for me)
even tried and it did not fix it (for me)
<ListView.Resources>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Right" />
</Style>
</ListView.Resources>
解决方案
Have a look here:
http://highfieldtales.wordpress.com/2013/11/10/hacking-the-wpf-gridview-two-more-features/
It's a series of posts by me on how to hack the GridView, and get some hidden gem from it.