Class Viewbox
Defines a content decorator that can stretch and scale a single child to fill the available space.
Inheritance
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.dll
Syntax
[TemplatePart(Name = "Child", Type = typeof(ContentPresenter))]
public class Viewbox : ContentControl, IControl, IFrameworkElement, IUIElement, IDependencyObject
Constructors
| Improve this Doc View SourceViewbox()
Initializes a new instance of the Viewbox class.
Declaration
public Viewbox()
Fields
| Improve this Doc View SourceChildProperty
Identifies the Child dependency property.
Declaration
public static readonly DependencyProperty ChildProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
StretchDirectionProperty
Identifies the StretchDirection dependency property.
Declaration
public static readonly DependencyProperty StretchDirectionProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
StretchProperty
Identifies the Stretch dependency property.
Declaration
public static readonly DependencyProperty StretchProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
Properties
| Improve this Doc View SourceChild
Gets or sets the single child element of a Viewbox element.
Declaration
public UIElement Child { get; set; }
Property Value
Type | Description |
---|---|
UIElement | The single child element of a Viewbox element. |
Stretch
Gets or sets the Stretch mode, which determines how content fits into the available space.
Declaration
public Stretch Stretch { get; set; }
Property Value
Type | Description |
---|---|
Stretch | A Stretch mode, which determines how content fits in the available space. The default is Uniform. |
StretchDirection
Gets or sets the StretchDirection, which determines how scaling is applied to the contents of a Viewbox.
Declaration
public StretchDirection StretchDirection { get; set; }
Property Value
Type | Description |
---|---|
StretchDirection | A StretchDirection, which determines how scaling is applied to the contents of a Viewbox. The default is Both. |
Methods
| Improve this Doc View SourceArrangeOverride(Size)
Arranges the content of a Viewbox element. Viewbox always sets the child to its desired size. It then computes and applies a transformation from that size to the space available: Viewbox's own input size less child margin.
Declaration
protected override Size ArrangeOverride(Size finalSize)
Parameters
Type | Name | Description |
---|---|---|
Size | finalSize | The Size this element uses to arrange its child content. |
Returns
Type | Description |
---|---|
Size | The Size that represents the arranged size of this Viewbox element and its child. |
Overrides
| Improve this Doc View SourceMeasureOverride(Size)
Measures the child element of a Viewbox to prepare for arranging it during the ArrangeOverride pass.
Declaration
protected override Size MeasureOverride(Size availableSize)
Parameters
Type | Name | Description |
---|---|---|
Size | availableSize | An upper limit Size that should not be exceeded. |
Returns
Type | Description |
---|---|
Size | The target Size of the element. |
Overrides
Remarks
Viewbox measures it's child at an infinite constraint; it allows the child to be however large it so desires. The child's returned size will be used as it's natural size for scaling to Viewbox's size during Arrange.
OnApplyTemplate()
Builds the visual tree for the Viewbox control when a new template is applied.
Declaration
public override void OnApplyTemplate()
Overrides
| Improve this Doc View SourceOnSizeChanged(Object, SizeChangedEventArgs)
Declaration
protected virtual void OnSizeChanged(object sender, SizeChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | |
SizeChangedEventArgs | e |