Re: Calendar SelectedDates quirk? [wpf:61002

Jul 21, 2009 at 5:21 PM
Thanks Eric,

I'll give it a try ;-) Seems like WPF is a bit on the bleeding edge right now. On another note, I have been trying to set the text alignment of a single column of a ListView control with very little luck. It just seems so normal that some columns might need a different alignment strategy than others. I've gotten pretty close with the code below, but the TextAlignment="Center" below has no effect. Am I missing something here? Is there a more correct way to accomplish this? I have two columns specified below, which are bound to the MovieList ObservableCollection. Right now I have to set the Margin property on the TextBlock inside the DataTemplate to move the text in the column cells such that they look a bit more "centered".

<ListView Grid.Row="1" Name="lstMovies" Margin="10" Height="Auto" ItemsSource="{Binding ElementName=This, Path=MovieList}"
SelectionChanged="lstMovies_SelectionChanged" MouseDoubleClick="lstMovies_MouseDoubleClick">
<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!


-----Original Message-----
From: ericf <notifications@codeplex.com>
To: [email removed]
Sent: Mon, Jul 20, 2009 11:30 pm
Subject: Re: Calendar SelectedDates quirk? [wpf:61002]

From: ericf
Hi Hanoverian -
I was able to reproduce your issue and a bug has been filed in our database. I have devised a temporary work-around for you. It may not be the best or the most appropriate, but it should work for your scenario. I highly suggest that you thoroughly test it as it is not guarenteed at all. With that said, you'll have to modify the source code in SelectedDatesCollection.cs, in the ClearItems() function, add the following line after this._owner.SelectedDate = null : this._owner.HoverStart = null;
Let me know if it works out for you :-)
-Eric, MSFT
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 21, 2009 at 8:14 PM
Edited Jul 21, 2009 at 8:15 PM

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