2

Hi I am experiencing a similiar problem to this Question.

Whats different for me is that I am using in my WinForms-MainForm the "CreateParams-Method" to force doublebuffering. Code for this is (following e.g. DataGridView draws wrong):

protected override CreateParams CreateParams
{
    get
    {
        // Activate double buffering at the form level.  All child controls will be double buffered as well.
        CreateParams cp = base.CreateParams;
        cp.ExStyle |= 0x02000000;   // WS_EX_COMPOSITED
        return cp;
    }
} 

My problem is now, as long as this CreateParams is activated, the content of my WPF-ElementHost in a WinForms-Usercontrol are only drawn when there is a mouseover event.

Short description: The UserControl "opens" but it's transparent. After I move over it with my mouse, e.g. the ComboBoxes get drawn.

As soon as I comment out the CreateParams everything works just fine (with the WPF-ElementHost). Is it possible to just deactivate / use different CreateParams for the WPFElementHost?

Community
  • 1
  • 1
basti
  • 2,649
  • 3
  • 31
  • 46

1 Answers1

0

Changing the render mode on the WPF control worked for me:

private void Control_Loaded(object sender, RoutedEventArgs e)
{
    HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
    HwndTarget hwndTarget = hwndSource.CompositionTarget;
    hwndTarget.RenderMode = RenderMode.SoftwareOnly;
}
Community
  • 1
  • 1
Eduardo Wada
  • 2,606
  • 19
  • 31
  • I can't reproduce this anymore, it's been a while.. ..so sorry for not accepting your answer :/ – basti Jul 08 '15 at 15:41
  • 1
    Actually, I found later that this answer has a problem related to graphics drivers and will cause the entire system to crash on some computers http://stackoverflow.com/q/17473857/1102585 , it works fine for most but 1 out of 5 machines I tested crashed with this solution – Eduardo Wada Jul 08 '15 at 17:55