Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public static void UpdateContentLayout(this UI.Xaml.Controls.Button mauiButton,
content.LayoutImageLeft(spacing);
break;
}

content.InvalidateMeasure();
}

public static void UpdateLineBreakMode(this Microsoft.UI.Xaml.Controls.Button platformButton, Button button)
Expand Down
44 changes: 42 additions & 2 deletions src/Controls/tests/DeviceTests/Elements/Layout/LayoutTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,47 @@ await AttachAndRun(grid, (handler) =>
});
}

/* Commented out of for now due to inconsistent platform behavior
[Fact]
[Category(TestCategory.Button, TestCategory.FlexLayout)]
public async Task ButtonWithImageInFlexLayoutInGridDoesNotCycle()
{
EnsureHandlerCreated((builder) =>
{
builder.ConfigureMauiHandlers(handler =>
{
handler.AddHandler(typeof(Button), typeof(ButtonHandler));
handler.AddHandler(typeof(Layout), typeof(LayoutHandler));
});
});

await ButtonWithImageInFlexLayoutInGridDoesNotCycleCore();
// Cycle does not occur on first run
await ButtonWithImageInFlexLayoutInGridDoesNotCycleCore();
}

async Task ButtonWithImageInFlexLayoutInGridDoesNotCycleCore()
{
var grid = new Grid() { MaximumWidthRequest = 150 };
grid.AddRowDefinition(new RowDefinition(GridLength.Auto));

var flexLayout = new FlexLayout() { Wrap = Layouts.FlexWrap.Wrap };
grid.Add(flexLayout);

for (int i = 0; i < 2; i++)
{
var button = new Button { ImageSource = "black.png" };
flexLayout.Add(button);
}

await InvokeOnMainThreadAsync(async () =>
{
// If this can be attached to the hierarchy and make it through a layout
// without crashing, then we're good.
await AttachAndRun(grid, (handler) => { });
});
}

/* Commented out of for now due to inconsistent platform behavior
[Fact("Ensures grid rows renders the correct size - Issue 15330")]
public async Task Issue15330()
{
Expand Down Expand Up @@ -401,7 +441,7 @@ public async Task Issue15330()
Assert.Equal(bitmap.Height / 3 * 2, cyanBlob.MinRow, 2d);
}*/

[Fact]
[Fact]
public async Task DependentLayoutBindingsResolve()
{
EnsureHandlerCreated((builder) =>
Expand Down
Binary file modified src/Controls/tests/UITests/snapshots/windows/Issue21513Test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions src/Core/src/Platform/Windows/ButtonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ public static void UpdateImageSource(this Button platformButton, WImageSource? n
{
if (platformButton.GetContent<WImage>() is WImage nativeImage)
{
// Stretch to fill
nativeImage.Stretch = UI.Xaml.Media.Stretch.Uniform;

// If we're a CanvasImageSource (font image source), we need to explicitly set the image height
// to the desired size of the font, otherwise it will be stretched to the available space
if (nativeImageSource is CanvasImageSource canvas)
Expand Down
Loading