In my application, on menu click we are launching a window. While loading, window will be black for few seconds and then controls will appears. I have attached the image here for reference. Please help me . .
Asked
Active
Viewed 1,247 times
-1

mm8
- 163,881
- 10
- 57
- 88

Naveenkumar R
- 89
- 2
- 15
-
Your question is missing a description of desired behavior. – grek40 Jan 04 '17 at 11:34
2 Answers
0
Do you import and use WindowChrome class (System.Windows.Shell) in your project? when i import this class to my project this problem happened.

mohsen mousavi
- 262
- 2
- 7
-
No. we are not using WindowChrome class in our project.but we are importing [DllImport("user32.dll")] – Naveenkumar R Jan 04 '17 at 10:25
-
1
-
-
Can i use any other dll instead user32.dll to solve this problem? – Naveenkumar R Jan 04 '17 at 13:18
0
You should read this:
How to fix the WPF form resize - controls lagging behind and black background?
You can change the colour of the black bit that shows by calling the SetClassLong method as suggested by @@ghord:
public static class WindowExtensions
{
private const int GCL_HBRBACKGROUND = -10;
private const int COLOR_WINDOW = 5;
public static void SetClassLong(this Window window)
{
//change the background colour of the window to "hide" possible black rendering artifacts
IntPtr handle = new WindowInteropHelper(window).EnsureHandle();
if (handle != IntPtr.Zero)
SetClassLong(handle, GCL_HBRBACKGROUND, SafeNativeMethods.GetSysColorBrush(COLOR_WINDOW));
}
private static IntPtr SetClassLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
{
if (IntPtr.Size > 4)
return SafeNativeMethods.SetClassLongPtr64(hWnd, nIndex, dwNewLong);
else
return new IntPtr(SafeNativeMethods.SetClassLongPtr32(hWnd, nIndex, unchecked((uint)dwNewLong.ToInt32())));
}
}
public partial class MainWindow : Window, IViewFor<MainWindowViewModel>
{
public MainWindow()
{
InitializeComponent();
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
//change the background colour of the window to "hide" possible black rendering artifacts
this.SetClassLong();
}
}
-
Can you suggest any other solution other than setting background brush.? Because i tried with all suggested solutions above but did't work for me... – Naveenkumar R Jan 05 '17 at 03:47