ConstrainedBox Class

Definition

The ConstrainedBox is a Windows.UI.Xaml.FrameworkElement control akin to Windows.UI.Xaml.Controls.Viewbox which can modify the behavior of it's child element's layout. ConstrainedBox restricts the available size for its content based on a scale factor, multiple factor, and/or a specific AspectRatio, in that order. This is performed as a layout calculation modification.

public class ConstrainedBox : Windows.UI.Xaml.Controls.ContentPresenter
type ConstrainedBox = class
    inherit ContentPresenter
Public Class ConstrainedBox
Inherits ContentPresenter
Inheritance
Windows.UI.Xaml.Controls.ContentPresenter
ConstrainedBox

Remarks

Note that this class being implemented as a Windows.UI.Xaml.Controls.ContentPresenter is an implementation detail, and is not meant to be used as one with a template. It is recommended to avoid styling the frame of the control with borders and not using Windows.UI.Xaml.Controls.ContentPresenter.ContentTemplate for future compatibility of your code if moving to WinUI 3 in the future.

Constructors

ConstrainedBox()

Fields

AspectRatioProperty

Identifies the AspectRatio property.

MultipleXProperty

Identifies the MultipleX property.

MultipleYProperty

Identifies the MultipleY property.

ScaleXProperty

Identifies the ScaleX property.

ScaleYProperty

Identifies the ScaleY property.

Properties

AspectRatio

Gets or sets aspect Ratio to use for the contents of the Panel (after scaling).

MultipleX

Gets or sets the integer multiple that the width of the panel should be floored to. Default is null (no snap).

MultipleY

Gets or sets the integer multiple that the height of the panel should be floored to. Default is null (no snap).

ScaleX

Gets or sets the scale for the width of the panel. Should be a value between 0-1.0. Default is 1.0.

ScaleY

Gets or sets the scale for the height of the panel. Should be a value between 0-1.0. Default is 1.0.

Methods

ArrangeOverride(Size)
MeasureOverride(Size)

Applies to