Skip to content
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

Disable WinFormsAvaloniaControlHost in design mode #16296

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

daniel-lerch
Copy link
Contributor

What does the pull request do?

This pull request disables the creation of an EmbeddableControlRoot in WinFormsAvaloniaControlHost when it is in design mode, i.e. run by the Windows Forms designer.

Furthermore, I added a rectangle with a caption Avalonia control is disabled in design mode. which is rendered in design mode only to inform help developers find their control in the designer and give them a hint why they cannot see their Avalonia control.

What is the current behavior?

When you add a WinFormsAvaloniaControlHost to your Form, the control throws an exception.

image
First, you will be shown this message box by Visual Studio every time you open the designer which is very annoying.

image
Secondly, in place of your control host the designer will render a big error message which is hard to ignore while using the designer for other controls.

What is the updated/expected behavior with this PR?

image
Now, the control does not throw an exception anymore and the designer instead shows a subtle hint that the Avalonia control is disabled.

How was the solution implemented (if it's not obvious)?

Just two simple if conditions. If WinFormsAvaloniaControlHost should become more complex in the future it might make sense to split the runtime and the designer implementation into two different classes.

Checklist

Fixed issues

Fixes #16288

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0050032-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@cla-avalonia
Copy link
Collaborator

cla-avalonia commented Jul 12, 2024

  • All contributors have signed the CLA.

@daniel-lerch
Copy link
Contributor Author

@cla-avalonia agree

@maxkatz6 maxkatz6 added bug os-windows backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch labels Jul 12, 2024
Copy link
Member

@maxkatz6 maxkatz6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

@maxkatz6 maxkatz6 added this pull request to the merge queue Jul 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 12, 2024
@daniel-lerch
Copy link
Contributor Author

Thank you very much for the quick reactions.

Interestingly, your macOS integration tests (merge queue) fail although I only changed a Windows only component 🙃

@maxkatz6
Copy link
Member

@daniel-lerch there are some flaky tests, especially on macOS. And when one fails - the rest will fail too. Unfortunately, it's way too difficult to setup integrational tests well.
But yes, this PR didn't break them.

@maxkatz6 maxkatz6 merged commit 671a13d into AvaloniaUI:master Jul 12, 2024
11 checks passed
@daniel-lerch daniel-lerch deleted the winforms-ava-control-host branch July 13, 2024 06:37
@maxkatz6 maxkatz6 added backported-11.1.x and removed backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch labels Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WinFormsAvaloniaControlHost throws an exception in designer
4 participants