In This Article

SettingsGroup

The SettingsCard, SettingsExpander, and SettingsGroup controls are used together to organize and present configurable settings.

Screenshot

SettingsCard and SettingsExpander displayed within a SettingsGroup

A SettingsGroup is used to organize one or more SettingsCard or SettingsExpander instances under an optional header.

Screenshot

SettingsGroup with optional header and description displaying a SettingsCard and SettingsExpander as child settings

Important

See the Getting Started topic for details on configuring themes for this control.

Primary Content Areas

The SettingsGroup control is defined by multiple content areas:

  • Header - The primary label for the group.
  • Description - An additional description for the group.

Each content area can optionally be set to any value supported by ContentPresenter and the layout will adjust to only show the areas where content is defined.

Note

In some scenarios, content may not be automatically detected. For instance, if a DataTemplate is used to define content without setting the corresponding content property, the control will not know that content is available. Use the IsHeaderVisible and IsDescriptionVisible properties to manually control the visibility of each content area.

Header and Description

The Header and Description are typically string values describing the group, and both are optional. The following demonstrates how to create a SettingsGroup with a header and description:

xmlns:actipro="http://schemas.actiprosoftware.com/avaloniaui"
...
<actipro:SettingsGroup Header="Group name" Description="Use the description for additional context">

	<!-- Define child settings here -->

</actipro:SettingsGroup>

Items (Child Settings)

The SettingsGroup is an ItemsControl that supports defining one or more SettingsCard or SettingsExpander instances as child settings that displayed within the group.

The following sample demonstrates defining a SettingsGroup with multiple child settings:

xmlns:actipro="http://schemas.actiprosoftware.com/avaloniaui"
...
<actipro:SettingsGroup Header="Group name" ... >

	<actipro:SettingsCard Header="Child setting">
		<ComboBox> ... </ComboBox>
	</actipro:SettingsCard>

	<actipro:SettingsExpander Header="Child setting">

		<actipro:SettingsCard Header="Expander child setting">
			<ToggleSwitch actipro:ThemeProperties.ToggleSwitchHasFarAffinity="True" />
		</actipro:SettingsCard>

	</actipro:SettingsExpander>

</actipro:SettingsGroup>

See the SettingsCard and SettingsExpander topics for more details.

Spacing

Each SettingsCard or SettingsExpander within a group is automatically spaced out to improve visibility. Use the Spacing property to change the amount of spacing between each item.

Screenshot

SettingsGroup showing ItemsHeader and ItemsFooter

SettingsGroup allows for additional content to be displayed above and below the child settings. Any content supported by ContentPresenter can be defined in the ItemsHeader or ItemsFooter.

The following sample demonstrates adding an informational message in the ItemsHeader:

xmlns:actipro="http://schemas.actiprosoftware.com/avaloniaui"
...
<actipro:SettingsGroup Header="Group name" ... >

	<actipro:SettingsGroup.ItemsHeader>
		<Border Background="{actipro:ThemeResource Container3BackgroundBrush}"
				BorderBrush="{actipro:ThemeResource Container3BorderBrush}"
				BorderThickness="1" Padding="12,2" CornerRadius="5"
				Margin="0,0,0,10">
			<TextBlock TextWrapping="Wrap">Any content can be displayed in the header</TextBlock>
		</Border>
	</actipro:SettingsGroup.ItemsHeader>

	<!-- Define child settings here -->

</actipro:SettingsGroup>
Note

In some scenarios, content may not be automatically detected. For instance, if a DataTemplate is used to define content without setting the corresponding content property, the control will not know that content is available. Use the IsItemsHeaderVisible and IsItemsFooterVisible properties to manually control the visibility of each content area.

StackPanel and Margin

The SettingsGroup is designed to be stacked vertically within a StackPanel with minimal effort. As part of this design, each SettingsGroup has a default Margin applied which includes spacing on the bottom. This will consistently separate one group from the group below it but does introduce extra spacing below the last item in a StackPanel. For many common layouts, this extra spacing may be inconsequential. If necessary, explicitly set the Margin of the last group to 0 to avoid the spacing.

The following sample demonstrates a common layout for defining multiple groups:

xmlns:actipro="http://schemas.actiprosoftware.com/avaloniaui"
...
<StackPanel>

	<actipro:SettingsGroup Header="Group 1">
		...
	</actipro:SettingsGroup>

	<actipro:SettingsGroup Header="Group 2">
		...
	</actipro:SettingsGroup>

	<actipro:SettingsGroup Header="Group 3" Margin="0">
		...
	</actipro:SettingsGroup>

</StackPanel>

Theme Resources

The following theme resources are available for customizing the appearance of the control:

Theme Resource Description
HeadingFontFamily The default FontFamily for the Header content.
HeadingFontSizeExtraSmall The default FontSize for the Header content.
DefaultFontSizeSmall The default FontSize for the Description content.
HeadingFontWeightExtraSmall The default FontWeight for the Header content.
DefaultForegroundBrush The default Foreground.
DefaultForegroundBrushTertiary The default Foreground of the Description content.
DefaultForegroundBrushDisabled The default Foreground when the control is disabled.
SettingsGroupMargin The default Margin.
SettingsGroupPadding The default Padding.
SettingsGroupSpacing The default Spacing.

See the Theme Assets topic for more details on working with theme resources.