Skip to content

[iOS] When setting ImageSource on a Button, LayoutOptions are completely ignored #18504

@Vetle444

Description

@Vetle444

Description

No matter what you set on HorizontalOptions and VerticalOptions, it is ignored when the ImageSource property is set on a Button. It works fine if the ImageSource property is not set.

NB! Version with bug is: 8.0.0-rc.2.9511 NOT 8.0.0-rc.2.9373. I could not find 8.0.0-rc.2.9511 in the list below.

Steps to Reproduce

Add a Button like so: <Button Text="This is a test" HorizontalOptions="Center" VerticalOptions="Center" BackgroundColor="Green" /> wrapped inside for example a Grid. Observe that the Button only uses the space that it needs to display the text.

Now add an ImageSource to the Button like so: <Button Text="This is a test" HorizontalOptions="Center" VerticalOptions="Center" BackgroundColor="Green" ImageSource="icon.png" />. Observe that the Button will use the whole space. It behaves exactly as if the VerticalOptions and HorizontalOptions are set to Fill

Link to public reproduction project repository

No response

Version with bug

8.0.0-rc.2.9373

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.0-rc.2.9373

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

You can set 'HeightRequest' and 'WidthRequest' to force the 'Button' to only use that much space. However, not feasible to use.

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

area-controls-buttonButton, ImageButtonfixed-in-8.0.6Look for this fix in 8.0.6 SR1!i/regressionThis issue described a confirmed regression on a currently supported versionplatform/iost/bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions