diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj index a82b094236d..95d4447d976 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj +++ b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj @@ -271,7 +271,7 @@ - + @@ -622,7 +622,7 @@ - + Designer @@ -1538,4 +1538,4 @@ - + \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Primitives/ConstrainedPresenter.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Primitives/ConstrainedBox.bind similarity index 80% rename from Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Primitives/ConstrainedPresenter.bind rename to Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Primitives/ConstrainedBox.bind index 05636fc23b0..221e46913b0 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Primitives/ConstrainedPresenter.bind +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Primitives/ConstrainedBox.bind @@ -7,8 +7,8 @@ mc:Ignorable="d"> - + - + diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Primitives/ConstrainedPresenter.png b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Primitives/ConstrainedBox.png similarity index 100% rename from Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Primitives/ConstrainedPresenter.png rename to Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Primitives/ConstrainedBox.png diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/XamlOnlyPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/XamlOnlyPage.xaml index 4edeb3ddab4..631cf5e5c95 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/XamlOnlyPage.xaml +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/XamlOnlyPage.xaml @@ -47,7 +47,7 @@ - + diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json index e6f041c0c55..ac8a2a97cae 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json @@ -477,13 +477,13 @@ "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/SwitchPresenter.md" }, { - "Name": "ConstrainedPresenter", + "Name": "ConstrainedBox", "Subcategory": "Layout", - "About": "The ConstrainedPresenter is a ContentPresenter which can allow a developer to constrain the scale or aspect ratio of its content.", - "CodeUrl": "https://github.com/CommunityToolkit/WindowsCommunityToolkit/tree/main/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedPresenter", - "XamlCodeFile": "/SamplePages/Primitives/ConstrainedPresenter.bind", - "Icon": "/SamplePages/Primitives/ConstrainedPresenter.png", - "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/ConstrainedPresenter.md" + "About": "The ConstrainedBox is a FrameworkElement which can allow a developer to constrain the scale or aspect ratio of its content.", + "CodeUrl": "https://github.com/CommunityToolkit/WindowsCommunityToolkit/tree/main/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedBox", + "XamlCodeFile": "/SamplePages/Primitives/ConstrainedBox.bind", + "Icon": "/SamplePages/Primitives/ConstrainedBox.png", + "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/ConstrainedBox.md" } ] }, diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedPresenter/AspectRatio.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedBox/AspectRatio.cs similarity index 98% rename from Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedPresenter/AspectRatio.cs rename to Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedBox/AspectRatio.cs index f2d2cf559a0..4475a247abf 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedPresenter/AspectRatio.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedBox/AspectRatio.cs @@ -7,7 +7,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls { /// - /// The structure is used by the control to + /// The structure is used by the control to /// define a specific ratio to restrict its content. /// [Windows.Foundation.Metadata.CreateFromString(MethodName = "Microsoft.Toolkit.Uwp.UI.Controls.AspectRatio.ConvertToAspectRatio")] diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedPresenter/ConstrainedPresenter.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedBox/ConstrainedBox.cs similarity index 76% rename from Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedPresenter/ConstrainedPresenter.cs rename to Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedBox/ConstrainedBox.cs index 49f7aebaacb..0b14ec3b282 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedPresenter/ConstrainedPresenter.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedBox/ConstrainedBox.cs @@ -14,10 +14,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls { /// - /// The is a control which can restrict the + /// The is a control akin to + /// which can modify the behavior of it's child element's layout. restricts the /// available size for its content based on a scale factor and/or a specific . + /// This is performed as a layout calculation modification. /// - public class ConstrainedPresenter : ContentPresenter // TODO: Think it should be a Border? But it's sealed; hopefully can change in WinUI 3. + /// + /// Note that this class being implemented as a 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 for future compatibility of your + /// code if moving to WinUI 3 in the future. + /// + public class ConstrainedBox : ContentPresenter // TODO: Should be FrameworkElement directly, see https://github.com/microsoft/microsoft-ui-xaml/issues/5530 { /// /// Gets or sets aspect Ratio to use for the contents of the Panel (after scaling). @@ -32,11 +40,11 @@ public AspectRatio AspectRatio /// Identifies the property. /// public static readonly DependencyProperty AspectRatioProperty = - DependencyProperty.Register(nameof(AspectRatio), typeof(AspectRatio), typeof(ConstrainedPresenter), new PropertyMetadata(null, AspectRatioPropertyChanged)); + DependencyProperty.Register(nameof(AspectRatio), typeof(AspectRatio), typeof(ConstrainedBox), new PropertyMetadata(null, AspectRatioPropertyChanged)); private static void AspectRatioPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - if (d is ConstrainedPresenter panel) + if (d is ConstrainedBox panel) { panel.InvalidateMeasure(); } @@ -55,7 +63,7 @@ public double ScaleX /// Identifies the property. /// public static readonly DependencyProperty ScaleXProperty = - DependencyProperty.Register(nameof(ScaleX), typeof(double), typeof(ConstrainedPresenter), new PropertyMetadata(1.0, ScalePropertyChanged)); + DependencyProperty.Register(nameof(ScaleX), typeof(double), typeof(ConstrainedBox), new PropertyMetadata(1.0, ScalePropertyChanged)); /// /// 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 /// Identifies the property. /// public static readonly DependencyProperty ScaleYProperty = - DependencyProperty.Register(nameof(ScaleY), typeof(double), typeof(ConstrainedPresenter), new PropertyMetadata(1.0, ScalePropertyChanged)); + DependencyProperty.Register(nameof(ScaleY), typeof(double), typeof(ConstrainedBox), new PropertyMetadata(1.0, ScalePropertyChanged)); private static void ScalePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - if (d is ConstrainedPresenter panel) + if (d is ConstrainedBox panel) { panel.InvalidateMeasure(); }