![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | Problem with alignment of text in a listview I am having problems getting a listview with a gridview to align the text within a cell. I downloaded the SDK sample "ListView That Uses a GridView with Templates Sample" from http://msdn2.microsoft.com/en-us/library/ms771780.aspx This includes a cell template that uses: <DataTemplate x:Key="myCellTemplateYear"> <DockPanel> <TextBlock Foreground="DarkBlue" HorizontalAlignment="Center"> <TextBlock.Text> <Binding Path="Year"/> </TextBlock.Text> </TextBlock> </DockPanel> </DataTemplate> I would expect this to align the "Year" in the "Center" of each cell. But this does not happen - it is always "Left" aligned. Is this a bug in WPF or in the SDK sample? Any hints on how to modify the sample to Right justify the Year would be greatly appreciated. Thanx |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Problem with alignment of text in a listview The ListViewItems that contain your cells default to Left content alignment. You can override that with this: <ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch"/> </Style> </ListView.ItemContainerStyle> "keithabarker" wrote: Quote: > I am having problems getting a listview with a gridview to align the text > within a cell. > > I downloaded the SDK sample "ListView That Uses a GridView with Templates > Sample" from http://msdn2.microsoft.com/en-us/library/ms771780.aspx > > This includes a cell template that uses: > > <DataTemplate x:Key="myCellTemplateYear"> > <DockPanel> > <TextBlock Foreground="DarkBlue" HorizontalAlignment="Center"> > <TextBlock.Text> > <Binding Path="Year"/> > </TextBlock.Text> > </TextBlock> > </DockPanel> > </DataTemplate> > > I would expect this to align the "Year" in the "Center" of each cell. > But this does not happen - it is always "Left" aligned. > > Is this a bug in WPF or in the SDK sample? > > Any hints on how to modify the sample to Right justify the Year would be > greatly appreciated. > > Thanx > |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Desktop icon text -alignment? | General Discussion | |||
| WPF ListView focus problem. | .NET General | |||
| HP PSC 2101 alignment problem | Vista print fax & scan | |||