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

Add support for the Developer Tools window in Avalonia controls embedded to Windows Forms #17927

Closed
xfortin-devolutions opened this issue Jan 8, 2025 · 4 comments

Comments

@xfortin-devolutions
Copy link

Is your feature request related to a problem? Please describe.

We are progressively integrating Avalonia UI elements to our WinForms application and, because of this, we setup Avalonia without a Lifetime, which prevents attaching the DevTools (AttachDevTools) for the whole application. It still works if we attach it on a per-Window basis, but I expect us to end up with a lot of UserControl embedded directly in Windows Forms (and View/Window for macOS, and for GTK in Linux).

Describe the solution you'd like

It would be nice to be able to open the DevTools for Avalonia UserControls embedded to WinForms with WinFormsAvaloniaControlHost.

The same would then apply to EmbeddableControlRoot in Mac and whatever it is for Linux (XEmbedPlug?)

Describe alternatives you've considered

No response

Additional context

No response

@maxkatz6
Copy link
Member

maxkatz6 commented Jan 8, 2025

It is already supported via this method:
public static void AttachDevTools(this TopLevel root)

@xfortin-devolutions
Copy link
Author

@maxkatz6 Neither WinFormsAvaloniaControlHost nor UserControls are TopLevel object though, no?

image
image

This is the method I use for the windows though.

image

@maxkatz6
Copy link
Member

@xfortin-devolutions inside of the Avalonia control code, "avaloniaView" code in your case, you can call TopLevel.GetTopLevel(control). Note, it should be done when control has attached to the visual tree.

@xfortin-devolutions
Copy link
Author

@maxkatz6 Yep! This works, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants