Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - How to right align text in a listview ?

 
 
Old 03-30-2007   #1 (permalink)
Pon


 
 

How to right align text in a listview ?

Hi all,
Simple question :
I try to right align textbox which display numbers in a listview column. But
it's as if WPF just ignore my statement. Looking closer i realised that the
textbox is well right align but it disgards my Width = Stretch setting and
make the textbox always sized to auto, just as if there were no parent to
size it (and indeed, there is no). I guess that's because the "container"
column is not a control. How to prevent that as there is no horizontal
alignment property on the column itself.

Thanx in advance.




My System SpecsSystem Spec
Old 04-13-2007   #2 (permalink)
Pon


 
 

Re: How to right align text in a listview ?

Nobody, really ?!!


My System SpecsSystem Spec
Old 04-14-2007   #3 (permalink)
Plamen Ratchev


 
 

Re: How to right align text in a listview ?

You can define a Style to the ListViewItem, like this:

<Style x:Key="ListItemStyle" TargetType="{x:Type ListViewItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>

Then apply the style:

<ListView ItemContainerStyle="{StaticResource ListItemStyle}">
<ListView.View>
<GridView>
<GridViewColumn Header="Right Aligned Numbers" Width="200"/>
</GridView>
</ListView.View>
<TextBox TextAlignment="Right">1</TextBox>
<TextBox TextAlignment="Right">2</TextBox>
</ListView>

This will give you stretched text box to fill the column with right
alignment.

HTH,

Plamen Ratchev
http://www.SQLStudio.com


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Display does not align text properly Vista General
How to Align Desktop items in VISTA??? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46