我正在使用MVVM設計模式創建WPF TimeCard應用程序,並且我試圖顯示用戶按每天分組計時的總和(總)小時數。我有一個列表視圖與所有的TimeCard數據分解成使用以下XAML組:在ListView中顯示分組項目的總和
<ListView.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource GroupItemStyle}">
<GroupStyle.HeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name, StringFormat=\{0:D\}}" FontWeight="Bold"/>
<TextBlock Text=" (" FontWeight="Bold"/>
<!-- This needs to display the sum of the hours -->
<TextBlock Text="{Binding ???}" FontWeight="Bold"/>
<TextBlock Text=" hours)" FontWeight="Bold"/>
</StackPanel>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
這甚至可能嗎?起初我以爲我會創建一個CollectionViewGroup的部分類並添加我自己的屬性。但我不確定這將會起作用。也許有更好的解決方案...有什麼建議嗎?
謝謝!我總是會忘記你可以用ValueConverters做的所有事情。感謝您的示例代碼。 – Brent 2010-02-12 04:36:53
如果值改變,這將不起作用。 – 2011-08-10 19:15:46