-
Notifications
You must be signed in to change notification settings - Fork 116
Fix WrapPanel stretching behavior for last item #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5072d89
cece15f
121a7e3
feeeb46
a45fd9b
5b689fa
c11407c
ce3e862
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using CommunityToolkit.Tests; | ||
using CommunityToolkit.WinUI.Controls; | ||
|
||
namespace PrimitivesTests; | ||
|
||
[TestClass] | ||
public class Test_WrapPanel_Infinity : VisualUITestBase | ||
{ | ||
[TestCategory("WrapPanel")] | ||
[TestMethod] | ||
public async Task Test_WrapPanel_InfinityWidth_WithStretchChild_Last() | ||
{ | ||
await App.DispatcherQueue.EnqueueAsync(async () => | ||
{ | ||
var treeRoot = XamlReader.Load(@"<Page | ||
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" | ||
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" | ||
xmlns:controls=""using:CommunityToolkit.WinUI.Controls""> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width=""Auto"" /> | ||
</Grid.ColumnDefinitions> | ||
<controls:WrapPanel | ||
x:Name=""WrapPanel"" | ||
Grid.Column=""0"" | ||
StretchChild=""Last""> | ||
<Border /> | ||
<Border /> | ||
<Border /> | ||
</controls:WrapPanel> | ||
</Grid> | ||
</Page>") as FrameworkElement; | ||
|
||
Assert.IsNotNull(treeRoot, "Could not load XAML tree."); | ||
|
||
// Initialize Visual Tree | ||
await LoadTestContentAsync(treeRoot); | ||
|
||
var wrapPanel = treeRoot.FindChild("WrapPanel") as WrapPanel; | ||
Assert.IsNotNull(wrapPanel, "Could not find WrapPanel in tree."); | ||
Assert.IsTrue(wrapPanel.IsLoaded, "WrapPanel is not loaded."); | ||
Comment on lines
+43
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be good to test beyond just that things load here too. i.e. ensure it has three children and the last one is a fixed size. And also have the alternate case where the child is stretched in the normal case and check that it fills the width. Think that covers us. |
||
}); | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why this blank page was added with sample suffix? This can be used as the code to load for the test, see the other comment. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Page x:Class="PrimitivesTests.WrapPanelSample" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="using:CommunityToolkit.WinUI.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:PrimitivesTests" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" | ||
mc:Ignorable="d"> | ||
|
||
<!-- | ||
This is required for dynamic XAML loading. | ||
See https://github.com/CommunityToolkit/WindowsCommunityToolkit/issues/1961 | ||
--> | ||
<controls:WrapPanel /> | ||
|
||
</Page> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace PrimitivesTests; | ||
|
||
public sealed partial class WrapPanelSample : Page | ||
{ | ||
public WrapPanelSample() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use a page and the new source generator for this. e.g.
https://github.com/CommunityToolkit/Tooling-Windows-Submodule/blob/fa4dd480fda756e4d503bea17629eda6c89afae0/ProjectTemplate/tests/ExampleProjectTemplateTestClass.cs#L53-L60
https://github.com/CommunityToolkit/Tooling-Windows-Submodule/tree/main/ProjectTemplate/tests