![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Simplest way to right-align GridViewColumn I've got a ListView, containing some numbers (currency and others), and would like to be able to right-align the columns with numbers. Since I can't find any tag on GridViewColumn to change the alignment, whats the easiest way to achieve this? Thanks, Sam |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Simplest way to right-align GridViewColumn Sam Jost wrote: > I've got a ListView, containing some numbers (currency and others), > and would like to be able to right-align the columns with numbers. > > Since I can't find any tag on GridViewColumn to change the alignment, > whats the easiest way to achieve this? I believe you'll need to define a CellTemplate for the column. In the template just put a TextBlock and set it's TextAlignment to TextAlignment.Right. That would look something like this: <GridViewColumn ...> <GridViewColumn.CellTempate> <DataTemplate> <TextBlock Text="{Binding Path=???}" TextAlignment="Right" /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> HTH, Drew ___________________________________ Drew Marsh Chief Software Architect Mimeo.com, Inc. - http://www.mimeo.com Microsoft C# / WPF MVP Weblog - http://blog.hackedbrain.com/ |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Simplest way to right-align GridViewColumn Drew, I had to change it a bit to make it work, but it does the trick. In the end for me it looks like: <ListView.Resources> <DataTemplate x:Key="MyTemplate"> <TextBlock HorizontalAlignment="Right" Block.TextAlignment="Right" Text="{Binding Path=MyData}"/> </DataTemplate> </ListView.Resources> [...] <GridViewColumn Width="80" Header="my data" CellTemplate="{StaticResource MyTemplate}"/> Thanks for the hint! Sam Drew Marsh schrieb: > Sam Jost wrote: > > > I've got a ListView, containing some numbers (currency and others), > > and would like to be able to right-align the columns with numbers. > > > > Since I can't find any tag on GridViewColumn to change the alignment, > > whats the easiest way to achieve this? > > I believe you'll need to define a CellTemplate for the column. In the template > just put a TextBlock and set it's TextAlignment to TextAlignment.Right. That > would look something like this: > > <GridViewColumn ...> > <GridViewColumn.CellTempate> > <DataTemplate> > <TextBlock Text="{Binding Path=???}" TextAlignment="Right" /> > </DataTemplate> > </GridViewColumn.CellTemplate> > </GridViewColumn> > > HTH, > Drew > ___________________________________ > Drew Marsh > Chief Software Architect > Mimeo.com, Inc. - http://www.mimeo.com > Microsoft C# / WPF MVP > Weblog - http://blog.hackedbrain.com/ |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to Align Desktop items in VISTA??? | vamshi | Vista General | 4 | 07-17-2008 09:12 AM |
| Simplest (Vista-compatible) macro-maker ??? | Vengeful | Vista General | 0 | 12-09-2007 12:31 PM |
| auto align icons horizontally | Jeremy Schubert | Vista General | 0 | 07-08-2007 03:36 PM |
| How to right align text in a listview ? | Pon | Avalon | 2 | 04-14-2007 02:13 PM |
| appyling styles to a GridViewColumn | Jason Dolinger | Avalon | 15 | 02-21-2006 01:36 PM |