GridView控件右对齐CellTemplate [英] GridView Right Align CellTemplate

查看:264
本文介绍了GridView控件右对齐CellTemplate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何将TextBlock是右对齐

 < GridViewColumn WIDTH =45>
    < GridViewColumnHeader CONTENT =#督Horizo​​ntalContentAlignment =左/>
    < GridViewColumn.CellTemplate>
        <的DataTemplate>
            < TextBlock的TextWrapping =NoWrap的TextAlignment =右的Horizo​​ntalAlignment =右
                文本={绑定路径=伯爵的StringFormat = {} {0:N0},模式=单向}/>
        < / DataTemplate中>
    < /GridViewColumn.CellTemplate>
< / GridViewColumn>
 

Horizo​​ntalContentAlignment和TextAlignment不解决它(对我来说)

甚至尝试,并没有解决它(对我来说)

 < ListView.Resources>
    <风格的TargetType =ListViewItem的>
        < setter属性=Horizo​​ntalContentAlignmentVALUE =右/>
    < /样式和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.

这篇关于GridView控件右对齐CellTemplate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆