Skip to content

GLWpfControl.Loaded event doesn't seem to be called, unless an additional delegate is added #125

@chadvandy

Description

@chadvandy

Having a strange behavior where the GLWpfControl.OnLoaded() method, which just invalidates the visual of the control once it's loaded to be properly drawn, isn't run automatically, unless I specifically assign a new delegate to GLWpfControl.Loaded.

public DrawingDemo()
{
	Debug.WriteLine("Creating the DemoControl!");
	InitializeComponent();

	DemoControl.Loaded += ControlLoaded;
	Loaded += OnLoad;
	Unloaded += OnUnload;
}

private void ControlLoaded(object sender, RoutedEventArgs e)
{
	Debug.WriteLine("DemoControl loaded by OpenGL!");
}

If I comment out DemoControl.Loaded += ControlLoaded:
image
image

  • The OpenGL Content remains grey until I manually resize the window.

If I keep it in:
image
image

  • Automatically renders the drawn content, since InvalidateVisual() is called very early.

I'm using the LearnOpenTK tutorial right now, and I do understand there are some differences between the base assumption implementation (having the GameWindow and such) versus how it works in GLWpfControl, so I'm sure I may be misunderstanding something.
 
Using OpenTK 4.8.2, GLWpfControl 4.2.3, .NET Core 8.0.4, Visual Studio 2022 17.9.6.

Thanks for your help, and thanks for this project!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions