Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3933662
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:37:35+00:00 2026-05-19T23:37:35+00:00

I have a WPF user control for which I need to force rendering in

  • 0

I have a WPF user control for which I need to force rendering in RenderMode.SoftwareOnly. Since I am using .NET 3.5, I had to do something like this:

var hwndSource = PresentationSource.FromVisual(this) as HwndSource;
if (hwndSource != null)
{
    hwndSource.CompositionTarget.RenderMode = RenderMode.SoftwareOnly;        
}

But this is not working on my application, The WPF program is crashing on few machines and turning off the hardware acceleration at the registry level seems to fix the issue.

The above code is written in the Loaded event of the window. If I am correct, Loaded event happens after the controls are rendered (MSDN). So does it make sense to have the above code in that event? If not, which event would be appropriate for it?

Also, will setting RenderMode on a visual affects its children? Or do I need to set this specifically for each child elements?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:37:36+00:00Added an answer on May 19, 2026 at 11:37 pm

    Here’s what we did:

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        if (ForceSoftwareRendering)
        {
            HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
            HwndTarget hwndTarget = hwndSource.CompositionTarget;
            hwndTarget.RenderMode = RenderMode.SoftwareOnly;
        }
    }
    

    It worked OK for us, EXCEPT… This needs to be done for every Window. In .NET 3.5 there was no way to make the setting take effect application-wide. And there are some windows that you won’t have as much control over – for example, right-click "context" windows. We found that there was no good solution for .NET 3.5 except the registry setting.

    Edited

    Here’s the logic we used to determine when to force software rendering. It was suggested by a Microsoft support engineer.

    public bool ForceSoftwareRendering 
    {
        get 
        { 
            int renderingTier = (System.Windows.Media.RenderCapability.Tier >> 16);
            return renderingTier == 0;
        }
    }
    

    In .NET 4 Microsoft added an application-wide setting that works perfectly for us. Its a much better option because you don’t need to set it on every window. You just set it once and it applies to all windows.

    System.Windows.Media.RenderOptions.ProcessRenderMode

    Edited

    The new .NET 4.0 property can be set at application startup like this:

    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            if (ForceSoftwareRendering)
                RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF window for editing database information, which is represented using an
I have a complex WPF UserControl made of other ContentControl templates which contain sets
I have WPF ListBox which is bound to a ObservableCollection, when the collection changes,
I have a WPF Window which has a among other controls hosts a Frame.
I have a WPF control, that has a list of Investors, and in the
I have a really simple WPF UserControl: <UserControl x:Class=dr.SitecoreCompare.WPF.ConnectionEntry xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml x:Name=connEntry BorderBrush=Navy BorderThickness=1
In a WPF UserControl, I have to make to call to a WebService. I
I have a WPF project and I'm trying to setup a NAnt build script
I have a WPF application in VS 2008 with some web service references. For
I have several wpf pages with update/delete/add buttons. I want to display to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.