9

I have an outlook addin that adds a custom taskpane to the right side of Outlook Explorer. In the taskpane I have added a UserControl that contains an ElementHost. The ElementHost has as a Child a WPF UserControl with many WPF elements.

The addin works nicely, except when I resize the custom taskpane to reduce its size, the content of the control often doesn't get repainted correctly. Instead I get white rectangles all over the custom taskpane. An example of this can be seen on the attached image. What is really strange to me is that the position of rectangles is not limited to the content of the ElementHost, but to the whole content of the taskpane - you can see that the top rectangle is covering the lower part of the taskpane's title bar.

Any suggestions what could be causing the issue and how to fix it?

Thanks,

Gregor

enter image description here

Gregor Leban
  • 553
  • 4
  • 17

1 Answers1

0

Seems like the correct solution for this is disabling hardware acceleration for the WPF controls.

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

Taken from here: https://www.add-in-express.com/forum/read.php?FID=5&TID=8618

almulo
  • 4,918
  • 1
  • 20
  • 29