This project is read-only.


WPF Composites supports customizing the "look and feel" of the Expander in a fine-grained manner. You may pass in any content to the Initialize call for use as the Header Content. Yet, this will typically be a Label. In fact, it is worth noting that the ChangeExpanderSkin convenience method does expect a Label as the HeaderContent and will likely throw a null reference exception if you fail to use one. Just an FYI.

Besides ChangeExpanderSkin which has many parameters to change the colors of a given Expander, there is also an ApplyExpanderStrategy method. This is very similar except that it has fewer parameters, so choose this briefer signature, if desired. Both will allow defining both an Expanded and a Collapsed Arrow Geometry for if you wish to change the default figure of the up and down arrow in the Expander's Toggle Button to something else.

In other regards, the Expander works very much like other WPF Composites in that you may define a Container Type to wrap the Expander's body Content in (as opposed to the Header Content which is not wrapped.)

Expander expa = new Expander();

expa.IsExpanded = true;
expa.Initialize(810D, 180D, ContainerType.VerticalPanel, new Label() { Content = "Expander with a Toolbar Tray inside", Background = Brushes.White});

                .AddExisting<ToolBarTray, Expander>(0, 0, tTray)
                .AddText<Expander>(0, 1, "Some text beneath the toolbar tray")
                .AddFlatButton<Expander>(0, 2, 150D, 30D, "Change Expander", Brushes.Black, new Thickness(1), Brushes.Snow, new CornerRadius(3D), new Thickness(1), new Thickness(1), Brushes.Red, (o, args) =>
                    expa.ChangeExpanderSkin(Brushes.LightSalmon, Brushes.LightSalmon, "Green", "Khaki", "Gold", "Purple", "Green", "Gold", "Orange", "M 0, 5 H 5 M 5, 0 V 5 Z", "M 1,1.5 L 4.5,5 L 8,1.5", ExpanderExt.Shape.Rectangle);

                .EndComposite<Expander, ExpanderArgs>(null);

expa.Background = Brushes.White;
expa.ApplyExpanderStrategy("Orange", "Red", "Blue", "Purple", "Green", "Gold", "Transparent", ExpanderExt.Shape.Rectangle); 
If you need to change the skin of an Expander within a ListBox or a ListView, then the call is different. Use the Contemporary Style's convenience method CreateExpanderForGroupItem method call instead:

ContemporaryStyle.CreateExpanderForGroupItem(null, true, Brushes.Blue, new Thickness(0, 0, 0, 1), "White", "White", "Gold", "Gold", "Yellow", "Yellow", "DarkBlue", ExpanderExt.Shape.Ellipse)) 
This helper method is meant to be leveraged either when (a) originally defining the settings of the ListBox or ListView, e.g. within the SetGroupExpanderFrameworkElementFactory method, or when (b) updating the existing GroupStyle. See the documentation for Group Descriptions for more details.

Last edited Jun 13, 2013 at 12:20 AM by stagathome0069, version 14


No comments yet.