locked
WPF Window with black background flashes white when first shown RRS feed

  • Question

  • We have a Kiosk application that starts some small specialized WPF applications to display certain content. Several of those can be visible at the same time (for example one might show a slide show while an other one shows a video on a different part of the screen). The kiosk computer's desktop background is set to black, and so are the window backgrounds of all the WPF windows.

    But whenever a new window is launched, its background flashes white for a brief moment.

    All that is needed to reproduce the behaviour is to create a new WPF application, set the window's background to black, and start the application. When started from within Visual Studio the effect is very noticeable. When running without the debugger that white flash is much shorter, but still noticeable since everything else is black.

    I have already tried everything I could think of (including redefining SystemColors.WindowBrushKey to black), but without success.

    We are using .Net4 and all the windows have WindowState.Normal.

    Is there a way we can avoid the flicker?

    Thursday, October 28, 2010 1:02 PM

Answers

  • Hi bsm'rubin,

    Thank you for your feedback!

    As far as I can see, this is a known issue in WPF. Currently our developers are aware of this issue already. They will take this into serious account when designing the future releases of the products.

    For your reference, I hope you could read this thread http://stackoverflow.com/questions/2364340/how-can-i-avoid-flicker-in-a-wpf-fullscreen-app.

    Improving the quality of the products and services is a never-ending process for Microsoft. Thanks again for choosing us.

     

    Best regards,

    Yves


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Yves.Z Thursday, November 4, 2010 11:54 AM
    Monday, November 1, 2010 12:17 PM

All replies

  • Hi bsm'rubin,

    Thank you for your feedback!

    As far as I can see, this is a known issue in WPF. Currently our developers are aware of this issue already. They will take this into serious account when designing the future releases of the products.

    For your reference, I hope you could read this thread http://stackoverflow.com/questions/2364340/how-can-i-avoid-flicker-in-a-wpf-fullscreen-app.

    Improving the quality of the products and services is a never-ending process for Microsoft. Thanks again for choosing us.

     

    Best regards,

    Yves


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Yves.Z Thursday, November 4, 2010 11:54 AM
    Monday, November 1, 2010 12:17 PM
  • Since I found this in a google search, and arrived at an answer, here's what I suggest:

    in App.xaml.cs

    protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e);

    MainWindow = new MainWindow(); // always start minimized. It prevents a white flash MainWindow.WindowState = WindowState.Minimized; // show in task bar must not be set to false here or it // messes with the window displaying properly. MainWindow.Show();

    Remove StartupUri from App.xaml

    In MainWindow.xaml.cs constructor, before calling InitializeComponent()

    Loaded += MainWindow_Loaded;

    Finally:

    private void MainWindow_Loaded(object sender, RoutedEventArgs e)
            {
    // Start the app minimized, then show it here to avoid a white flash on startup
                    Activate();
                    WindowState = WindowState.Normal;
    }

    • Proposed as answer by Jimes7 Tuesday, August 1, 2017 11:18 PM
    Tuesday, December 8, 2015 9:45 PM
  • Hi bsm'rubin,

    Thank you for your feedback!

    As far as I can see, this is a known issue in WPF. Currently our developers are aware of this issue already. They will take this into serious account when designing the future releases of the products.

    For your reference, I hope you could read this thread http://stackoverflow.com/questions/2364340/how-can-i-avoid-flicker-in-a-wpf-fullscreen-app.

    Improving the quality of the products and services is a never-ending process for Microsoft. Thanks again for choosing us.

     

    Best regards,

    Yves


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Whis is this still unresolved 8 years later.....
    Wednesday, November 28, 2018 3:13 PM
  • Thank you for the pointer. This problem has been bugging me for a very long time.

    Using the exact solution you describe did indeed remove the white screen at the start, but replaced it with some coloured bars (looked like a huge version of a part of a button).

    Setting the WindowState in ContentRendered appears to have done the trick.


    BTW there is a second solution suggested somewhere else which involves making the window transparent on startup. For this AllowsTransparency has to be true and that can severely affect the performance of an application (especially notable on 4K resolution). AllowsTransparency can't be changed afterwards, so for us this didn't really work, but it would make it possible to do a nifty fade animation to make your window show up.


    • Edited by Remcoid Wednesday, July 17, 2019 3:50 PM
    Wednesday, July 17, 2019 3:49 PM
  • Hi

    By the looks of this post I think I am having the exact same issue. 

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/d9c81dd8-7ca2-4ad9-a26a-c4dc435e8bc9/white-colour-background-display-before-application-loads?forum=vcgeneral#d83292a7-816e-48b7-8e12-9443bb0ced31

    Please can you have a look at this post that I have posted up and tell me if it the same issue as you have experienced and if the soltuions you have provided to me can be used to resolve this issue.

    Thanks


    Monday, September 30, 2019 11:22 AM
  • Found it of being a terrible issue, and  Jimes7 had provided a nice solution;

    however, had made it more clean and simple;

    public partial class App : System.Windows.Application
    {
    
      internal App()
      {
        var v90 = new System.Windows.Window();
        {
          v90.Loaded += MainWindow_Loaded;
          System.Windows.NameScope.SetNameScope(v90,new System.Windows.NameScope());
          MainWindow.WindowState = System.Windows.WindowState.Minimized;
        }
        v90.Show();
      }
    
      private void MainWindow_Loaded(object sender,System.Windows.RoutedEventArgs e)
      {
        ((System.Windows.Window)sender).WindowState = System.Windows.WindowState.Normal;
      }
    
    }


    Friday, January 24, 2020 7:16 PM