14
14
namespace Microsoft . Toolkit . Uwp . UI . Controls
15
15
{
16
16
/// <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
18
19
/// 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.
19
21
/// </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
21
29
{
22
30
/// <summary>
23
31
/// Gets or sets aspect Ratio to use for the contents of the Panel (after scaling).
@@ -32,11 +40,11 @@ public AspectRatio AspectRatio
32
40
/// Identifies the <see cref="AspectRatio"/> property.
33
41
/// </summary>
34
42
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 ) ) ;
36
44
37
45
private static void AspectRatioPropertyChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
38
46
{
39
- if ( d is ConstrainedPresenter panel )
47
+ if ( d is ConstrainedBox panel )
40
48
{
41
49
panel . InvalidateMeasure ( ) ;
42
50
}
@@ -55,7 +63,7 @@ public double ScaleX
55
63
/// Identifies the <see cref="ScaleX"/> property.
56
64
/// </summary>
57
65
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 ) ) ;
59
67
60
68
/// <summary>
61
69
/// 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
70
78
/// Identifies the <see cref="ScaleY"/> property.
71
79
/// </summary>
72
80
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 ) ) ;
74
82
75
83
private static void ScalePropertyChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
76
84
{
77
- if ( d is ConstrainedPresenter panel )
85
+ if ( d is ConstrainedBox panel )
78
86
{
79
87
panel . InvalidateMeasure ( ) ;
80
88
}
0 commit comments