How to manage the layout and its elements

You can modify interface elements (controls) by changing directly manageable colors – a theme color (ThemeColor) and background color (ThemeBackground) – in the Interface Configuration panel or by adjusting elements globally (all controls of the same type at once) in the Global Elements panel or locally (independently per view) in the Layout Management panel. Changing any control parameter locally is treated with a higher priority than when changing it globally.

Layout.Id

Layout management depends on a number of factors. Primarily, a view must be properly registered (using the RegisterViews method from the ModuleBase class) and a relevant view model for the design mode (DesignViewModel) must be created. It is also necessary to assign an appropriate attribute to controls.

The attribute is Layout.Id and it must be unique within the entire POS application. This is essential to make it possible for a control to be manageable independently. If more than one control has the same ID, changing a property for only one of them will affect them all.

Setting default values for manageable properties

Default control values can be set up in several ways, depending on your needs.

1. Directly, as the attributes of a defined control in the xaml

<TextBlock Foreground="Red"/>

The control above will not be manageable, as the Layout.Id attribute has not been defined for it.

You can also combine this with color schemes and font:

<TextBlock Foreground="{DynamicResource ThemeColor}"/>

The control will only be manageable through the change of a color theme (a font color will be changed).

For a control to be manageable globally in the global interface configuration, it needs to be registered using the RegisterControl method from the ModuleBase class.

For a control to be manageable locally per view where it has been used (layout management), the view must be properly registered (using the RegisterViews method) and the control must have the Layout.Id attribute. When using Layout.Id, default control properties should not be set up directly in the control. If a default value, such as Foreground, is defined before determining Layout.Id, the value will be ignored. In turn, defining Foreground after Layout.Id will make the property unmanageable (it will always be overwritten with the directly set-up value).

Attributes should be set up directly only for unmanageable properties, such as ones that are not required for a control to work properly (e.g., Binding).

2. Control’s global style or local style (using x:Key)

<core:View.Resources>
        <Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
            <Setter Property="Foreground" Value="Red"/>
            <Setter Property="Background" Value="{DynamicResource ThemeBackground}"/>
        </Style>
</core:View.Resources>
..
<TextBlock core:Layout.Id="TextBlockLayoutId" />

The example above illustrates global settings for the style of the font and background color of all TextBlock controls used within the current view <core:View>.

<core:View.Resources>
        <Style x:Key="TextBlockStyle" 
               TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
            <Setter Property="Foreground" Value="Red"/>
            <Setter Property="Background" Value="{DynamicResource ThemeBackground}"/>
        </Style>
</core:View.Resources>
…
<TextBlock Style="{StaticResource TextBlockStyle}" core:Layout.Id="TextBlockLayoutId" />

The modification above presents how to use styles in order to set up only a selected control.

3. Default attribute defined in ModernUI.xaml according to the definition attribute_type x:Key=”[LayoutId].Default.[type_name]”>[default value]</attribute_type>

ModernUI.xml file

<SolidColorBrush x:Key="TextBlockLayoutId.Default.Foreground" Color="Red"/>

View file

<TextBlock core:Layout.Id="TextBlockLayoutId" />

The prerequisite for the example above to work properly is to register ModernUI.xaml resources of the module in the class registering the module (see the chapter New module in How to create views). In the constructor, it is necessary to call:

LayoutService.RegisterResources(typeof(Module));

This approach involves certain limitations, as it does not allow defining dynamic values and grouping recurrent values under a common name. For instance, it is not correc to use the following code:

<SolidColorBrush x:Key="TextBlockLayoutId.Default.Foreground" 
            Color="{DynamicResource ThemeColor}"/>

In this case, the type Color (System.Windows.Media.Color) and ThemeColor (SolidColorBrush) are incompatible!

Using this method is currently not recommended, except when defining default parameters for DataGrid columns.

Supported properties

The tables below list properties manageable in the interface configuration panel for individual controls available in POS application.

Control type

PropertyName
Supported property [name : type]Property name in the management panel

FrameworkElement

System.Windows.FrameworkElement

PropertyName
Width : doubleWidth
Height : doubleHeight
Margin : ThicknessMargin
HorizontalAlignment : HorizontalAlignmentAlign Horizontally
VerticalAlignment : VerticalAlignmentAlign Vertically
MaxWidth : doubleMax. Width
MaxHeight : doubleMax. Height
Grid.Position : stringArea

Control

System.Windows.Controls.Control

PropertyName
Background : BrushBackground
Foreground : BrushForeground
FontSize : doubleFont Size
FontWeight : FontWeightFont Weight
FontStyle : FontStyleFont Style
Padding : ThicknessPadding
Grid.Position : stringArea

Grid

System.Windows.Controls.Grid

PropertyName
Background : BrushBackground
Margin : ThicknessMargin
Visibility: VisibilityVisibility
Width: doubleWidth
Height: doubleHeight
Grid.Position : stringArea

Comarch.POS.Presentation.Core.Controls.Grid
: System.Windows.Controls.Grid

PropertyName
ColumnDefinition : stringColumns
RowDefinition : stringRows

Border

System.Windows.Controls.Border

PropertyName
Visibility : VisibilityVisibility
Background : BrushBackground

ScrollViewer

System.Windows.Controls.ScrollViewer
: System.Windows.Controls.Control

PropertyName
VerticalScrollBarVisibility : ScrollBarVisibilityVertical Scroll Bar
HorizontalSchrollBarVisibility : ScrollBarVisibilityHorizontal Scroll Bar
Width: doubleWidth
Height : doubleHeight

Comarch.POS.Presentation.Core.Controls.ScrollViewer
: System.Windows.Controls.ScrollViewer

PropertyName

Separator

System.Windows.Controls.Separator
: System.Windows.FrameworkElement

PropertyName
Background : BrushBackground

TextBlock

System.Windows.Controls.TextBlock
: System.Windows.FrameworkElement

PropertyName
Background : BrushBackground
Foreground : BrushForeground
FontSize : doubleFont Size
FontWeight : FontWeightFont Weight
FontStyle : FontStyleFont Style
Padding : ThicknessPadding
TextAlignment : TextAlignmentAlign Text
Visibility : VisibilityVisibility
TextWrapping : TextWrappingWrap Text

DoubleColorTextBlock

Comarch.POS.Presentation.Core.Controls.DoubleColorTextBlock
: System.Windows.FrameworkElement

PropertyName
FirstForeground : BrushForeground 1
SecondForeground : BrushForeground 2
Background : BrushBackground
FontSize : doubleFont Size
FontWeight : FontWeightFont Weight
FontStyle : FontStyleFont Style
Padding : ThicknessPadding
Visibility : VisibilityVisibility

ErrorTextBlock

Comarch.POS.Presentation.Core.Controls.ErrorTextBlock
: System.Windows.Controls.TextBlock

PropertyName

TextBox

Comarch.WPF.Controls.TextBox
: System.Windows.FrameworkElement,
System.Windows.Controls.Control

PropertyName
BorderThickness : ThicknessBorder
BorderBrush : BrushBorder Color
FocusedBorderBrush : BrushBorder Color (Focus)
ErrorColor : BrushError Color
HintForeground : BrushHint Foreground
Hint: stringHint Foreground

Comarch.POS.Presentation.Core.Controls.TextBox
: Comarch.WPF.Controls.TextBox

PropertyName

Underline

Comarch.WPF.Controls.Underline
: System.Windows.FrameworkElement

PropertyName
Stroke : BrushColor
StrokeThickness : ThicknessThickness

Comarch.POS.Presentation.Core.Controls.Underline
: Comarch.WPF.Controls.Underline

PropertyName

ColumnDefinition

System.Windows.Controls.ColumnDefinition

PropertyName
Width : doubleWidth

RowDefinition

System.Windows.Controls.RowDefinition

PropertyName
Height : doubleHeight

DataGridColumn

System.Windows.Controls.DataGridColumn

PropertyName
MaxWidth : doubleMax. Width
MinWidth : doubleMax. Height
Width : DataGridLengthWidth
SortDirection : ListSortDirectionSort Direction
Visibility : VisibilityVisibility
HorizontalAlignment : HorizontalAlignmentAlign Horizontally

DataGridTemplateColumn

System.Windows.Controls.DataGridTemplateColumn
: System.Windows.Controls.DataGridColumn

PropertyName

DataGridTextColumn

System.Windows.Controls.DataGridTextColumn
: System.Windows.Controls.DataGridColumn

PropertyName
FontSize : doubleFont Size
Foreground : BrushForeground
FontWeight : FontWeightFont Weight
FontStyle : FontStyleFont Style

DataGridCell

System.Windows.Controls.DataGridCell

PropertyName
Margin : ThicknessMargin
HorizontalAlignment : HorizontalAlignmentAlign Horizontally

DataGridColumnHeader

System.Windows.Controls.Primitives.DataGridColumnHeader

PropertyName
Margin : ThicknessMargin
HorizontalContentAlignment : HorizontalAlignmentHorizontal Content Alignment

DataGrid

Comarch.WPF.Controls.DataGrid
: System.Windows.FrameworkElement,
System.Windows.Controls.Control

PropertyName

Comarch.POS.Presentation.Core.Controls.DataGrid

PropertyName
RowBackground : BrushRow Background Color
HeaderBackground : BrushHeader Background
ScrollBarWidth : doubleScroll Bar Width
VerticalScrollBarVisibility : VisibilityVertical Scroll Bar
HorizontalScrollBarVisibility : VisibilityHorizontal Scroll Bar
GroupBy : DataGridGroupGroup By
IsVirtualizingWhenGrouping : boolVirtualize Records
ScrollUnit : ScrollUnitScroll Unit
Grid.Position : stringArea

ItemsContainer

Comarch.POS.Presentation.Core.Controls.ItemsContainer
: System.Windows.FrameworkElement

PropertyName
Orientation : OrientationOrientation
Padding : ThicknessPadding
Background : BrushBackground
MoreMultiButtonHeight : doubleHeight
MoreMultiButtonWidth : doubleWidth
MoreMultiButtonImageHeight : doubleIcon Height
MoreMultiButtonImageWidth : doubleIcon Width
MoreMultiButtonMargin : ThicknessMargin
MoreMultiButtonImageMargin : Thickness Icon Margin
MoreMultiButtonFontSize : doubleFont Size
MoreMultiButtonIsImageVisible : boolShow Icon

Expander

Comarch.POS.Presentation.Core.Controls.Expander
: System.Windows.FrameworkElement,
System.Windows.Controls.Control

PropertyName
HeaderBackground : BrushHeader Background
HeaderPadding : ThicknessHeader Padding

Image

System.Windows.Controls.Image
: System.Windows.FrameworkElement

PropertyName
Stretch : StretchStretch
StretchDirection : StretchDirectionStretch Direction

Comarch.WPF.Controls.Image

PropertyName
HorizontalAlignment : HorizontalAlignmentAlign Horizontally
HorizontalContentAlignment : HorizontalAlignmentHorizontal Content Alignment
VerticalAlignment : VerticalAlignmentAlign Vertically
VerticalContentAlignment : VerticalAlignmentVertical Content Alignment

Comarch.POS.Presentation.Core.Controls.Image
: System.Windows.FrameworkElement

PropertyName
DefaultImageKey : ImageKeyDefault Icon

BundleImage

Comarch.POS.Presentation.Core.Controls.BundleImage

PropertyName
IconForeground : BrushColor
IconMargin : ThicknessMargin
IconImageKey : ImageKeyIcon
Width : doubleWidth
Height : doubleHeight
PopupMaxWidth : doubleMax. Width
PopupMinWidth : doubleMax. Height

Button

Comarch.POS.Presentation.Core.Controls.Button
: System.Windows.FrameworkElement,
System.Windows.Controls.Control

Other based on Button, such as:

Comarch.POS.Presentation.Core.Controls.AcceptButton
Comarch.POS.Presentation.Core.Controls.CancelButton
Comarch.POS.Presentation.Core.Controls.SelectButton
Comarch.POS.Presentation.Core.Controls.CleanButton
Comarch.POS.Presentation.Core.Controls.TileButton
Comarch.POS.Presentation.Core.Controls.PaymentTypeTile
Comarch.POS.Presentation.Core.Controls.PrintLabelButton
Comarch.POS.Presentation.Core.Controls. ShowItemsVariantsButton

PropertyName
ImageKey : ImageKeyIcon
ImageMargin : ThicknessIcon Margin
ImageWidth : doubleIcon Width
ImageHeight : doubleIcon Height
ImageHorizontalAlignment : HorizontalAlignmentAlign Horizontally
ImageVerticalAlignment : VerticalAlignmentAlign Vertically
IsImageVisible : boolShow Icon
ShortcutMargin : ThicknessMargin
ShortcutWidth : doubleWidth
ShortcutHeight : doubleHeight
ShortcutHorizontalAlignment : HorizontalAlignmentAlign Horizontally
ShortcutVerticalAlignment : VerticalAlignmentAlign Vertically
IsShortcutVisible : boolShow Hotkey
Shortcut : ShortcutHotkey
IsScaledShortcut : boolScale Content
ContentMargin : ThicknessMargin
ContentWidth : doubleWidth
ContentHeight : doubleHeight
ContentHorizontalAlignment : HorizontalAlignmentAlign Horizontally
ContentVerticalAlignment : VerticalAlignmentAlign Vertically
ContentVisibility : VisibilityVisibility
IsScaledContent : boolScale Content
Orientation : OrientationOrientation
ItemsContainer.NoWrapButton : boolDo not aggregate

RadioButton

Comarch.POS.Presentation.Core.Controls.RadioButton
: System.Windows.FrameworkElement,
System.Windows.Controls.Control

PropertyName
CheckedStateBackground : BrushSelected Element Background
CheckedStateForeground: BrushSelected Element Foreground
ImageKey : ImageKeyIcon
ImageMargin : ThicknessIcon Margin
ImageWidth : doubleIcon Width
ImageHeight : doubleIcon Height
ImageHorizontalAlignment : HorizontalAlignmentAlign Horizontally
ImageVerticalAlignment : VerticalAlignmentAlign Vertically
IsImageVisible : VisibilityShow Icon
ContentMargin : ThicknessMargin
ContentWidth : doubleWidth
ContentHeight : doubleHeight
ContentHorizontalAlignment : HorizontalAlignmentAlign Horizontally
ContantVerticalAlignment : VerticalAlignmentAlign Vertically
ContentVisibility : VisibilityVisibility
IsScaledContent : boolScale Content
Orientation : OrientantionOrientation

FieldControl

Comarch.POS.Presentation.Core.Controls.FieldControl
: System.Windows.FrameworkElement

PropertyName
Orientation : OrientationOrientation
LabelMargin : ThicknessMargin
LabelWidth : doubleWidth
LabelHeight : doubleHeight
LabelFontSize : doubleFont Size
LabelFontStyle : FontStyleFont Style
LabelFontWeight : FontWeightFont Weight
LabelForeground : BrushForeground
LabelForegroundError : BrushUnsuccessful Validation Color
LabelHorizontalAlignment: HorizontalAlignmentAlign Horizontally
LabelVertivalAlignment: VerticalAlignmentAlign Vertically
ContentIsRequired : boolRequired

CheckBox

Comarch.POS.Presentation.Core.Controls.CheckBox
: System.Windows.FrameworkElement,
System.Windows.Controls.Control

PropertyName
CheckedStateBackground : BrushSelected Element Background
CheckedStateForeground: BrushSelected Element Foreground
DisabledStateBackground : BrushDisabled Button B/G
DisabledCheckedStateBackground : BrushSelected Disabled Button B/G
ImageKey : ImageKeyIcon
ImageMargin : ThicknessIcon Margin
ImageWidth : doubleIcon Width
ImageHeight : doubleIcon Height
ImageHorizontalAlignment : HorizontalAlignmentAlign Horizontally
ImageVerticalAlignment : VerticalAlignmentAlign Vertically
IsImageVisible : VisibilityShow Icon
ContentMargin : ThicknessMargin
ContentWidth : doubleWidth
ContentHeight : doubleHeight
ContentHorizontalAlignment : HorizontalAlignmentAlign Horizontally
ContantVerticalAlignment : VerticalAlignmentAlign Vertically
ContentVisibility : VisibilityVisibility
IsScaledContent : boolScale Content
Orientation : OrientationOrientation

ComboBox

Comarch.WPF.Controls.ComboBox
: System.Windows.FrameworkElement,
System.Windows.Controls.Control

PropertyName
HorizontalContentAllignment : HorizontalAlignmentHorizontal Content Alignment
PopupBackground : BrushBackground
FocusedBorderBrush : BrushBorder Color (Focus)
ErrorColor : BrushError Color

Comarch.POS.Presentation.Core.Controls.ComboBox
: Comarch.WPF.Controls.TextBox

PropertyName

ComboBox2

Comarch.POS.Presentation.Core.Controls.ComboBox2

PropertyName
LabelFontSize : doubleFont Size
LabelFontStyle : FontStyleFont Style
LabelFontWeight : FontWeightFont Weight
Shortcut : ShortcutHotkey
FontSize : doubleFont Size
FontWeight : FontWeightFont Weight
FontStyle : FontStyleFont Style
Visibility : VisibilityVisibility

AutoCompleteComboBox

Comarch.POS.Presentation.Core.Controls.AutoCompleteComboBox
: System.Windows.Controls.Control

PropertyName
FocusedBorderBrush : BrushBorder Color (Focus)
ErrorColor : BrushError Color
HintForeground : BrushHint Foreground
Hint: stringHint

SwitchBox

Comarch.POS.Presentation.Core.Controls.SwitchBox
: System.Windows.Controls.Control

PropertyName
VerticalContentAlignment : VerticalAlignmentVertical Content Alignment
Margin : ThicknessMargin

Comarch.POS.Presentation.Core.Controls.SearchBox

PropertyName
FontSize : doubleFont Size
Foreground : BrushBackground
HintForeground : BrushHint Foreground
Margin: ThicknessMargin
Hint: stringHint

DatePicker

Comarch.POS.Presentation.Core.Controls.DatePicker
: System.Windows.Controls.Control

PropertyName
FocusedBorderBrush : BrushBorder Color (Focus)
ErrorColor : BrushError Color
BorderBrush : BrushBorder Color
Visibility : VisibilityVisibility

ButtonSpinner

Comarch.POS.Presentation.Core.Controls.ButtonSpinner

PropertyName
ButtonImageWidth : doubleWidth
ButtonImageHeight : doubleHeight
ButtonWidth : doubleButton Width
ButtonHeight : doubleButton Height

FilterItemsControl

Comarch.POS.Presentation.Core.Controls.FilterItemsControl

PropertyName
MaxFilterItemsPerRow : intMax. Number of Filters
Visibility : VisibilityVisibility
Grid.Position : stringArea

SearchBoxFilter

Comarch.POS.Presentation.Core.Controls.SearchBoxFilter
: Comarch.POS.Presentation.Core.Controls.ComboBox2

PropertyName
DefaultFilter : stringDefault Filter Value

StockTile

Comarch.POS.Presentation.Core.Controls.StockTile

PropertyName
Background : BrushBackground
IsCodeVisible : boolShow Warehouse Code
WarehouseMargin : ThicknessMargin
WarehouseCodeFontSize : doubleCode Font Size
WarehouseNameFontSize : doubleName Font Size
StocksFontSize : doubleFont Size
StocksMargin : ThicknessMargin

SetValueNumbersKeyboard

Comarch.WPF.Controls.SetValueNumbersKeyboard

PropertyName
Visibility : VisibilityVisibility

AttributeControl

Comarch.POS.Presentation.Core.Controls.AttributeControl
: System.Windows.Controls.Control

PropertyName

AssistantControl

Comarch.POS.Presentation.Core.Controls.AssistantControl

PropertyName
LabelFontSize : doubleFont Size
LabelFontStyle : FontStyleFont Style
LabelFontWeight : FontWeightFont Weight
FontSize : doubleFont Size
FontWeight : FontWeightFont Weight
FontStyle : FontStyleFont Style
Shortcut : ShortcutHotkey
Visibility : VisibilityVisibility
Grid.Position : stringArea

DocumentKeypad

Comarch.POS.Presentation.Core.Controls.DocumentKeypad

PropertyName
HeaderFontSize : double
KeypadHeaderColor : Brush

Czy ten artykuł był pomocny?