. In WPF Composites, you can likely achieve the same effect likely with both the ListBox and the ListView but for simplicity's sake and consistency, I only show the example of customizing a view with a ListView.
//Customize View for ListView - Expand All
myGrid.SubscribeEventOnChild<TextBlock, Grid>(gridguid3, 1, 0, "PreviewMouseDown", new MouseButtonEventHandler((o, ev) => {
myListView.BorderBrush = Brushes.Purple;
myListView.CustomizeView(bdr => {
customizeListView(bdr, true);
});
}));
//Customize View for ListView - Collapse All
myGrid.SubscribeEventOnChild<TextBlock, Grid>(gridguid3, 1, 1, "PreviewMouseDown", new MouseButtonEventHandler((o, ev) => {
myListView.BorderBrush = Brushes.Purple;
myListView.CustomizeView(bdr =>
{
customizeListView(bdr, false);
});
}));
. . . . . . . .
private void customizeListView(Border bdr, bool isExpanded)
{
string z = bdr.GetKey();
myListView.GetImage<ListView>(z, 0, 0).Visibility = Visibility.Collapsed;
myListView.GetTextBlock<ListView>(z, 1, 0).Background = Brushes.LightSalmon;
bdr.BorderThickness = new Thickness(5);
bdr.BorderBrush = Brushes.DarkGoldenrod;
#region Add new group label style
//step 1
FrameworkElementFactory factoryLabel = ContemporaryStyle.CreateLabelForGroupItem(34.0D, 334.0D, 17.0D, FontWeights.Bold, new Thickness(5, 0, 0, 0), Brushes.Orange, Brushes.AliceBlue, Brushes.Red, new Thickness(1), HorizontalAlignment.Left);
//step 2
FrameworkElementFactory factoryExpander = ContemporaryStyle.CreateExpanderForGroupItem(factoryLabel, isExpanded, Brushes.Green, new Thickness(0, 0, 0, 1), "Orange", "Red", "Blue", "Purple", "Green", "Gold", "Transparent", "M0,0 L0,5 L5,0 z", "M5,5 L0,5 L5,0 z", ExpanderExt.Shape.Rectangle);
//step 3
Style myStyle = ContemporaryStyle.CreateStyleForGroupItem(factoryExpander, new Thickness(1));
//step 4
GroupStyle groupStyle = new GroupStyle();
groupStyle.ContainerStyle = myStyle;
myListView.GroupStyle.Clear();
myListView.GroupStyle.Add(groupStyle);
#endregion
myListView.SetVerticalScrollThumbColors<ListView>("Orange", "Silver", "Gray", "Orange", "0", "0");
}