Skip to content

Commit 3b1518a

Browse files
Rename ConstrainedPresenter to ConstrainedBox
1 parent 39a95f2 commit 3b1518a

File tree

7 files changed

+28
-20
lines changed

7 files changed

+28
-20
lines changed

Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
<Content Include="SamplePages\Graph\LoginButton.png" />
272272
<Content Include="SamplePages\Graph\PeoplePicker.png" />
273273
<Content Include="SamplePages\Graph\PersonView.png" />
274-
<Content Include="SamplePages\Primitives\ConstrainedPresenter.png" />
274+
<Content Include="SamplePages\Primitives\ConstrainedBox.png" />
275275
<Content Include="SamplePages\Primitives\SwitchPresenter.png" />
276276
<Content Include="SamplePages\TabbedCommandBar\TabbedCommandBar.png" />
277277
<Content Include="SamplePages\Animations\Effects\FadeBehavior.png" />
@@ -622,7 +622,7 @@
622622
<Content Include="SamplePages\Graph\PeoplePickerXaml.bind" />
623623
<Content Include="SamplePages\Graph\PersonViewXaml.bind" />
624624
<Content Include="SamplePages\ListViewExtensions\ListViewExtensionsCode.bind" />
625-
<Content Include="SamplePages\Primitives\ConstrainedPresenter.bind">
625+
<Content Include="SamplePages\Primitives\ConstrainedBox.bind">
626626
<SubType>Designer</SubType>
627627
</Content>
628628
</ItemGroup>
@@ -1538,4 +1538,4 @@
15381538
</Target>
15391539
<!-- No-op to avoid build error when packing solution from commandline -->
15401540
<Target Name="Pack" />
1541-
</Project>
1541+
</Project>

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Primitives/ConstrainedPresenter.bind renamed to Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Primitives/ConstrainedBox.bind

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
mc:Ignorable="d">
88

99
<Grid>
10-
<controls:ConstrainedPresenter AspectRatio="16:3" VerticalAlignment="Top">
10+
<controls:ConstrainedBox AspectRatio="16:3" VerticalAlignment="Top">
1111
<Image Source="/Assets/Photos/WestSeattleView.jpg" Stretch="UniformToFill"/>
12-
</controls:ConstrainedPresenter>
12+
</controls:ConstrainedBox>
1313
</Grid>
1414
</Page>

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/XamlOnlyPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<controls:Case IsDefault="True" />
4848
</controls:CaseCollection>
4949
</controls:SwitchPresenter>
50-
<controls:ConstrainedPresenter x:Key="ConstrainedPresenterControl" />
50+
<controls:ConstrainedBox x:Key="ConstrainedBoxControl" />
5151
</Page.Resources>
5252

5353
<Grid>

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,13 @@
477477
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/SwitchPresenter.md"
478478
},
479479
{
480-
"Name": "ConstrainedPresenter",
480+
"Name": "ConstrainedBox",
481481
"Subcategory": "Layout",
482-
"About": "The ConstrainedPresenter is a ContentPresenter which can allow a developer to constrain the scale or aspect ratio of its content.",
483-
"CodeUrl": "https://github.com/CommunityToolkit/WindowsCommunityToolkit/tree/main/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedPresenter",
484-
"XamlCodeFile": "/SamplePages/Primitives/ConstrainedPresenter.bind",
485-
"Icon": "/SamplePages/Primitives/ConstrainedPresenter.png",
486-
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/ConstrainedPresenter.md"
482+
"About": "The ConstrainedBox is a FrameworkElement which can allow a developer to constrain the scale or aspect ratio of its content.",
483+
"CodeUrl": "https://github.com/CommunityToolkit/WindowsCommunityToolkit/tree/main/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedBox",
484+
"XamlCodeFile": "/SamplePages/Primitives/ConstrainedBox.bind",
485+
"Icon": "/SamplePages/Primitives/ConstrainedBox.png",
486+
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/ConstrainedBox.md"
487487
}
488488
]
489489
},

Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedPresenter/AspectRatio.cs renamed to Microsoft.Toolkit.Uwp.UI.Controls.Primitives/ConstrainedBox/AspectRatio.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Microsoft.Toolkit.Uwp.UI.Controls
88
{
99
/// <summary>
10-
/// The <see cref="AspectRatio"/> structure is used by the <see cref="ConstrainedPresenter"/> control to
10+
/// The <see cref="AspectRatio"/> structure is used by the <see cref="ConstrainedBox"/> control to
1111
/// define a specific ratio to restrict its content.
1212
/// </summary>
1313
[Windows.Foundation.Metadata.CreateFromString(MethodName = "Microsoft.Toolkit.Uwp.UI.Controls.AspectRatio.ConvertToAspectRatio")]
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@
1414
namespace 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

Comments
 (0)