I'm using WPF in WinForms with ElementHost. When the form loads, there is a flash of black background where the ElementHost is about to load. This looks kind of bad. Any suggestions on how to get rid of this?
+1
A:
Hide the element (Visibility = Hidden) until the WinForms control is fully loaded...
Thomas Levesque
2010-01-18 16:15:07
Yeah that would do it. I had to hide the ElementHost, though. If I just sat the wpf element to Visibility=Hidden, I still got the flash. But thanks for pointing me in the right direction.
Jostein
2010-01-19 13:17:54
A:
you need first show control with empty bounds first time to avoid black flickering
if (!_control.Created && _control.BackColor != Color.Transparent)
{
_control.Bounds = Rectangle.Empty;
_control.Show();
}
// set control bounds and show it
Rectangle bounds = GetBounds(context, rect);
if (_control.Bounds != bounds)
_control.Bounds = bounds;
if (!_control.Visible)
_control.Show();
Yuriy
2010-02-23 19:39:07