1
足够让我的头撞在我的键盘上。我有一个完美的作品像这样的列表视图:在代码背后创建并设计一个ListView全部在
FCView.FCListView.ItemsSource = myItemsSouce;
CollectionView view = CollectionViewSource.GetDefaultView(FCView.FCListView.ItemsSource) as CollectionView;
PropertyGroupDescription gd = new PropertyGroupDescription("Root");
view.GroupDescriptions.Add(gd);
现在我想要做的就是让这些组头大胆。 3个小时后,这是我能拿出最好的:
Style myStyle = new Style(typeof(GroupItem));
DataTemplate dt = new DataTemplate();
FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(GroupItem));
spFactory.SetValue(GroupItem.FontWeightProperty, FontWeights.Bold);
spFactory.SetValue(GroupItem.ForegroundProperty, new SolidColorBrush(Colors.Red));
dt.VisualTree = spFactory;
GroupStyle groupStyle = new GroupStyle();
groupStyle.HeaderTemplate = dt;
groupStyle.ContainerStyle = myStyle;
FCListView.GroupStyle.Add(groupStyle);
但这将覆盖我的GroupDescription除非我重新绑定它(这似乎是多余的,正确或者不工作)。有没有更简单的样式组头开(或,一样好,不风格其它列表视图组标题下的项目)