@@ -16,7 +16,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
16
16
/// <summary>
17
17
/// The <see cref="ConstrainedBox"/> is a <see cref="FrameworkElement"/> control akin to <see cref="Viewbox"/>
18
18
/// which can modify the behavior of it's child element's layout. <see cref="ConstrainedBox"/> restricts the
19
- /// available size for its content based on a scale factor and/or a specific <see cref="AspectRatio"/>.
19
+ /// available size for its content based on a scale factor, multiple factor, and/or a specific <see cref="AspectRatio"/>, in that order .
20
20
/// This is performed as a layout calculation modification.
21
21
/// </summary>
22
22
/// <remarks>
@@ -25,69 +25,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
25
25
/// with borders and not using <see cref="ContentPresenter.ContentTemplate"/> for future compatibility of your
26
26
/// code if moving to WinUI 3 in the future.
27
27
/// </remarks>
28
- public class ConstrainedBox : ContentPresenter // TODO: Should be FrameworkElement directly, see https://github.com/microsoft/microsoft-ui-xaml/issues/5530
28
+ public partial class ConstrainedBox : ContentPresenter // TODO: Should be FrameworkElement directly, see https://github.com/microsoft/microsoft-ui-xaml/issues/5530
29
29
{
30
- /// <summary>
31
- /// Gets or sets aspect Ratio to use for the contents of the Panel (after scaling).
32
- /// </summary>
33
- public AspectRatio AspectRatio
34
- {
35
- get { return ( AspectRatio ) GetValue ( AspectRatioProperty ) ; }
36
- set { SetValue ( AspectRatioProperty , value ) ; }
37
- }
38
-
39
- /// <summary>
40
- /// Identifies the <see cref="AspectRatio"/> property.
41
- /// </summary>
42
- public static readonly DependencyProperty AspectRatioProperty =
43
- DependencyProperty . Register ( nameof ( AspectRatio ) , typeof ( AspectRatio ) , typeof ( ConstrainedBox ) , new PropertyMetadata ( null , AspectRatioPropertyChanged ) ) ;
44
-
45
- private static void AspectRatioPropertyChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
46
- {
47
- if ( d is ConstrainedBox panel )
48
- {
49
- panel . InvalidateMeasure ( ) ;
50
- }
51
- }
52
-
53
- /// <summary>
54
- /// Gets or sets the scale for the width of the panel. Should be a value between 0-1.0. Default is 1.0.
55
- /// </summary>
56
- public double ScaleX
57
- {
58
- get { return ( double ) GetValue ( ScaleXProperty ) ; }
59
- set { SetValue ( ScaleXProperty , value ) ; }
60
- }
61
-
62
- /// <summary>
63
- /// Identifies the <see cref="ScaleX"/> property.
64
- /// </summary>
65
- public static readonly DependencyProperty ScaleXProperty =
66
- DependencyProperty . Register ( nameof ( ScaleX ) , typeof ( double ) , typeof ( ConstrainedBox ) , new PropertyMetadata ( 1.0 , ScalePropertyChanged ) ) ;
67
-
68
- /// <summary>
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
- /// </summary>
71
- public double ScaleY
72
- {
73
- get { return ( double ) GetValue ( ScaleYProperty ) ; }
74
- set { SetValue ( ScaleYProperty , value ) ; }
75
- }
76
-
77
- /// <summary>
78
- /// Identifies the <see cref="ScaleY"/> property.
79
- /// </summary>
80
- public static readonly DependencyProperty ScaleYProperty =
81
- DependencyProperty . Register ( nameof ( ScaleY ) , typeof ( double ) , typeof ( ConstrainedBox ) , new PropertyMetadata ( 1.0 , ScalePropertyChanged ) ) ;
82
-
83
- private static void ScalePropertyChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
84
- {
85
- if ( d is ConstrainedBox panel )
86
- {
87
- panel . InvalidateMeasure ( ) ;
88
- }
89
- }
90
-
91
30
private bool IsPositiveRealNumber ( double value ) => ! double . IsNaN ( value ) && ! double . IsInfinity ( value ) && value > 0 ;
92
31
93
32
private Size _lastMeasuredSize ;
0 commit comments