OnSourceInitialized for RadWindow

1 Answer 224 Views
Window
Bracco
Top achievements
Rank 1
Veteran
Bracco asked on 29 Jun 2021, 01:27 PM

I would like to know what's the equivalent of `OnSourceInitialized` for the `RadWindow`?

My need is to disable the WPF hardware acceleration for the window because of some calls to python with CUDA
causing WPF thread rendering issue.

How does one disable hardware acceleration in wpf? - Stack Overflow

Thank you,
Amaury

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 02 Jul 2021, 07:21 AM

Hello Bracco,

RadWindow is actually a content control which is hosted in a WPF native Window. You can use this information and the available API to set the RenderMode. You can get the host Window control using the HostCreated event of RadWindow. Then you can subscribe to the SourceInitialized event of the Window and set the RenderMode there. For example:

private void RadWindow_HostCreated(object sender, HostWindowCreatedEventArgs e)
{
	e.HostWindow.SourceInitialized += HostWindow_SourceInitialized;           
}

private void HostWindow_SourceInitialized(object sender, EventArgs e)
{
	var hwndSource = PresentationSource.FromVisual((Window)sender) as HwndSource;
	if (hwndSource != null)
		hwndSource.CompositionTarget.RenderMode = RenderMode.SoftwareOnly;
}

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Window
Asked by
Bracco
Top achievements
Rank 1
Veteran
Answers by
Martin Ivanov
Telerik team
Share this question
or