Re: Calendar SelectedDates quirk? [wpf:61002 [wpf:63103

Jul 21, 2009 at 11:37 PM
Awesome Eric! This was the missing piece! After stretching the TextBlocks across the ListView column, the TextAlignment property on the individual column took effect. I've been banging my head on the wall for some time now on this issue. It wasn't obvious that the TextBlock was not taking up the whole column width as it would be for TextBox controls. This really makes sense to me now. This is the final code:

<ListView Grid.Row="1" Name="lstMovies" Margin="10" Height="Auto" ItemsSource="{Binding ElementName=This, Path=MovieList}"
SelectionChanged="lstMovies_SelectionChanged" MouseDoubleClick="lstMovies_MouseDoubleClick">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="Title" Width="250" DisplayMemberBinding="{Binding Title}" />
<GridViewColumn Header="Movie ID" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding MovieID}" TextAlignment="Center" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>


Cheers,
Hanoverian (AKA John)


-----Original Message-----
From: ericf <notifications@codeplex.com>
To: [email removed]
Sent: Tue, Jul 21, 2009 3:14 pm
Subject: Re: Re: Calendar SelectedDates quirk? [wpf:61002 [wpf:63103]

From: ericf
Hello Again, Hanoverian -
The quirk you are experiencing is a common one. IanG explains it nicely at http://www.interact-sw.co.uk/iangblog/2007/05/30/fill-wpf-listview-columns
Try adding the following to your ListView:
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
-Eric, MSFT
<font size="2" color="#a31515"><font size="2" color="#a31515">
</font></font><font size="2" color="#a31515">
</font>
To add a post to this discussion, reply to this email (wpf@discussions.codeplex.com)
To start a new discussion for this project, email wpf@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


One-click access to hundreds of free games. Get the Games.com Toolbar.
Coordinator
Jul 22, 2009 at 12:45 AM

Glad I could help :) A simple/personal tip: when I'm having layout-related issues, I like to put a red border around the elements that aren't cooperating. It lets me see how much space they're actually taking up.

-Eric