Skip to main content

Properties

An inspector shows an object's settings as rows: a label on the left, an editor on the right. HammerUI builds it from two controls. PropertyGroup is a collapsible section with an icon, header actions and a menu. PropertyRow is one labelled row. The labels of every row in the panel share one column, which the user resizes by dragging its edge.

Example​

<ScrollViewer>
<StackPanel ui:PropertyGrid.LabelWidth="110">
<ui:PropertyGroup Header="Window" Icon="{x:Static ui:Icons.Monitor}">
<StackPanel>
<ui:PropertyRow Label="Title" Description="Shown in the title bar and the task switcher">
<TextBox Text="{Binding Title}" />
</ui:PropertyRow>
<ui:PropertyRow Label="Size">
<ui:Vector2Field Value="{Binding Size}" />
</ui:PropertyRow>
<ui:PropertyRow Label="Opacity" IsModified="{Binding IsOpacityModified}" ResetCommand="{Binding ResetOpacityCommand}">
<ui:NumberField Value="{Binding Opacity}" Minimum="0" Maximum="1" Step="0.05" FormatString="0.00" />
</ui:PropertyRow>
<ui:PropertyRow Label="Resizable">
<CheckBox IsChecked="{Binding IsResizable}" />
</ui:PropertyRow>
</StackPanel>
</ui:PropertyGroup>
</StackPanel>
</ScrollViewer>

PropertyGroup​

A HeaderedContentControl: the Header is the section title and the Content its rows.

PropertyDefaultWhat it does
HeaderThe title.
Icon, IconForegroundAn icon before the title, and its color.
IsExpandedtrueWhether the rows show. Clicking the header toggles it. Bound two-way.
HeaderActionsContent at the right of the header, such as an enable toggle or small icon buttons.
MenuA flyout of section commands, such as Reset, Copy or Remove. It opens from the header's more button and on right-click of the header.

PropertyRow​

PropertyWhat it does
LabelThe text in the label column.
DescriptionThe label's tooltip, typically what the property does.
ContentThe editor.
AccessoryA small control at the end of the label, such as a chip saying the value follows another.
IsModifiedMarks a value that differs from its default: the row shows an accent marker and a reset button.
ResetCommandRuns when the reset button is clicked. The row also raises ResetRequested.
LabelWidthThe label column's width, inherited from PropertyGrid.LabelWidth.

The label column​

PropertyGrid.LabelWidth is an attached, inherited property: set it on the panel that holds the groups, and every row below takes it. The default is 120.

Dragging the edge of a label sets the width for every row that shares it: rows under the element where PropertyGrid.LabelWidth is set, or else every row under the outermost group's parent. The width cannot go below 48.

In a row too narrow for its label and its value, the label column gives up width first, so the editor keeps enough room for a field of two numbers. LabelColumnWidth is the width the label takes in that row.