views:

339

answers:

2

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
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
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