Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Tue, 2 Oct 2007 07:18:00 -0700,    group: microsoft.public.windows.developer.winfx.avalon        back       


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
date: Tue, 2 Oct 2007 07:18:00 -0700   author:   keithabarker

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:

> 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
>
date: Wed, 24 Oct 2007 12:56:01 -0700   author:   Dayne Bratsman Dayne

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us