This topic has not yet been rated - Rate this topic

GroupStyle::HeaderStringFormat Property

Gets or sets a composite string that specifies how to format the header if it is displayed as a string.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
public:
property String^ HeaderStringFormat {
	String^ get ();
	void set (String^ value);
}
<object HeaderStringFormat="string" .../>

Property Value

Type: System::String
A composite string that specifies how to format the header if it is displayed as a string.

HeaderStringFormat can be a predefined, composite, or custom string format. For more information about string formats, see Formatting Types. If you set the HeaderTemplate or HeaderTemplateSelector property of a GroupStyle, the HeaderStringFormat property is ignored.

The following example creates a ListBox that groups a collection of items by price range. The converter, GroupByPrice, returns an integer value that is above each item's price. For example, if an item's price is between 0 and 100, the converter returns 100. The example uses the HeaderStringFormat to create a string that includes the upper limit for each price range. For example, in the United States, items that are under 100 dollars are grouped under a heading that says "Items under $100".

<StackPanel>
  <StackPanel.Resources>

      <src:ItemsForSale x:Key="MyData"/>
      <src:GroupByPrice x:Key="GroupByPrice"/>

      <CollectionViewSource x:Key="PriceGroup" Source="{StaticResource MyData}">

        <CollectionViewSource.GroupDescriptions>
          <PropertyGroupDescription PropertyName="Price"
                                    Converter="{StaticResource GroupByPrice}"/>
      </CollectionViewSource.GroupDescriptions>
    </CollectionViewSource>
  </StackPanel.Resources>

  <ListBox ItemsSource="{Binding Source={StaticResource PriceGroup}}"
           DisplayMemberPath="Description">
    <ListBox.GroupStyle>
      <GroupStyle HeaderStringFormat="Items under {0:c}"/>
    </ListBox.GroupStyle>
  </ListBox>
</StackPanel>

The following example shows the GroupByPrice class, the PurchaseItem class, and the collection that the ListBox is bound to.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5 SP1, 3.0 SP2

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.