【发布时间】:2015-12-29 05:37:18
【问题描述】:
我有一个 CollectionViewSource,它按 ObservableCollection 中的 Created 属性分组。分组在列表框中工作,但我无法获取标题文本以显示创建日期。
CollectionViewSource 如下:
<Window.Resources>
<CollectionViewSource x:Key="TaskListColSource" Source="{Binding Path=TaskItems}">
<CollectionViewSource.SortDescriptions>
<componentModel:SortDescription PropertyName="Created" />
</CollectionViewSource.SortDescriptions>
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="Created" />
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
</Window.Resources>
我的列表框组样式如下:
<ListBox.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Foreground" Value="White" />
<Setter Property="Focusable" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="True" Foreground="White">
<Expander.HeaderTemplate>
<DataTemplate DataType="{x:Type models:TaskItem}">
<TextBlock x:Name="asdf" Text="{Binding Created}" Foreground="White"/>
</DataTemplate>
</Expander.HeaderTemplate>
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListBox.GroupStyle>
谁能帮我在相关的文本块中显示创建日期?
我通过以下方式绑定列表框:
<ListBox x:Name="TaskListBox" ItemsSource="{Binding Source={StaticResource TaskListColSource}}">
【问题讨论】: