![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | 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) |
| | 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) |
| | 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 | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How to Align Desktop items in VISTA??? | Vista General | |||
| Simplest (Vista-compatible) macro-maker ??? | Vista General | |||
| auto align icons horizontally | Vista General | |||