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

WinFormsAvaloniaControlHost Not Displaying Content for .Net Framework Projects #18175

Open
conormcg94 opened this issue Feb 11, 2025 · 0 comments
Labels
bug help-wanted A contribution from the community would be most welcome. os-windows

Comments

@conormcg94
Copy link

Describe the bug

WinFormsAvaloniaControlHost is failing to display content for .Net Framework Projects. Content is displayed correctly when the framework is changed to net8.0-windows.

In my example I've set the host Content to a TextBlock. It only renders for net8.0-windows

net8.0-windows
Image

.Net Framework 4.8.1
Image

To Reproduce

I've attached a solution with two projects with identical code targeting .net481 and .net8.0-windows that demonstrates the problem

AvaloniaWinForms.zip

Program:

[STAThread]
static void Main()
{
	System.Windows.Forms.Application.EnableVisualStyles();
	System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

	Avalonia.AppBuilder.Configure<Avalonia.Application>()
			.UsePlatformDetect()
			.SetupWithoutStarting();

	System.Windows.Forms.Application.Run(new Form1());
} 

Form:

public partial class Form1 : Form
{
    private readonly WinFormsAvaloniaControlHost _host;

    public Form1()
    {
        InitializeComponent();
        _host = new()
        {
            Content = new Avalonia.Controls.TextBlock { Text = "Hello World" },
        };
        Controls.Add(_host);
    }
}

Expected behavior

No response

Avalonia version

11.2.3

OS

Windows

Additional context

No response

@conormcg94 conormcg94 added the bug label Feb 11, 2025
@maxkatz6 maxkatz6 added help-wanted A contribution from the community would be most welcome. os-windows labels Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help-wanted A contribution from the community would be most welcome. os-windows
Projects
None yet
Development

No branches or pull requests

2 participants