1414namespace Microsoft . Toolkit . Uwp . UI . Controls
1515{
1616 /// <summary>
17- /// The <see cref="ConstrainedPresenter"/> is a <see cref="ContentPresenter"/> control which can restrict the
17+ /// The <see cref="ConstrainedBox"/> is a <see cref="FrameworkElement"/> control akin to <see cref="Viewbox"/>
18+ /// which can modify the behavior of it's child element's layout. <see cref="ConstrainedBox"/> restricts the
1819 /// available size for its content based on a scale factor and/or a specific <see cref="AspectRatio"/>.
20+ /// This is performed as a layout calculation modification.
1921 /// </summary>
20- public class ConstrainedPresenter : ContentPresenter // TODO: Think it should be a Border? But it's sealed; hopefully can change in WinUI 3.
22+ /// <remarks>
23+ /// Note that this class being implemented as a <see cref="ContentPresenter"/> is an implementation detail, and
24+ /// is not meant to be used as one with a template. It is recommended to avoid styling the frame of the control
25+ /// with borders and not using <see cref="ContentPresenter.ContentTemplate"/> for future compatibility of your
26+ /// code if moving to WinUI 3 in the future.
27+ /// </remarks>
28+ public class ConstrainedBox : ContentPresenter // TODO: Should be FrameworkElement directly, see https://github.com/microsoft/microsoft-ui-xaml/issues/5530
2129 {
2230 /// <summary>
2331 /// Gets or sets aspect Ratio to use for the contents of the Panel (after scaling).
@@ -32,11 +40,11 @@ public AspectRatio AspectRatio
3240 /// Identifies the <see cref="AspectRatio"/> property.
3341 /// </summary>
3442 public static readonly DependencyProperty AspectRatioProperty =
35- DependencyProperty . Register ( nameof ( AspectRatio ) , typeof ( AspectRatio ) , typeof ( ConstrainedPresenter ) , new PropertyMetadata ( null , AspectRatioPropertyChanged ) ) ;
43+ DependencyProperty . Register ( nameof ( AspectRatio ) , typeof ( AspectRatio ) , typeof ( ConstrainedBox ) , new PropertyMetadata ( null , AspectRatioPropertyChanged ) ) ;
3644
3745 private static void AspectRatioPropertyChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
3846 {
39- if ( d is ConstrainedPresenter panel )
47+ if ( d is ConstrainedBox panel )
4048 {
4149 panel . InvalidateMeasure ( ) ;
4250 }
@@ -55,7 +63,7 @@ public double ScaleX
5563 /// Identifies the <see cref="ScaleX"/> property.
5664 /// </summary>
5765 public static readonly DependencyProperty ScaleXProperty =
58- DependencyProperty . Register ( nameof ( ScaleX ) , typeof ( double ) , typeof ( ConstrainedPresenter ) , new PropertyMetadata ( 1.0 , ScalePropertyChanged ) ) ;
66+ DependencyProperty . Register ( nameof ( ScaleX ) , typeof ( double ) , typeof ( ConstrainedBox ) , new PropertyMetadata ( 1.0 , ScalePropertyChanged ) ) ;
5967
6068 /// <summary>
6169 /// Gets or sets the scale for the height of the panel. Should be a value between 0-1.0. Default is 1.0.
@@ -70,11 +78,11 @@ public double ScaleY
7078 /// Identifies the <see cref="ScaleY"/> property.
7179 /// </summary>
7280 public static readonly DependencyProperty ScaleYProperty =
73- DependencyProperty . Register ( nameof ( ScaleY ) , typeof ( double ) , typeof ( ConstrainedPresenter ) , new PropertyMetadata ( 1.0 , ScalePropertyChanged ) ) ;
81+ DependencyProperty . Register ( nameof ( ScaleY ) , typeof ( double ) , typeof ( ConstrainedBox ) , new PropertyMetadata ( 1.0 , ScalePropertyChanged ) ) ;
7482
7583 private static void ScalePropertyChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
7684 {
77- if ( d is ConstrainedPresenter panel )
85+ if ( d is ConstrainedBox panel )
7886 {
7987 panel . InvalidateMeasure ( ) ;
8088 }
0 commit comments