wpfvisual-studioxamlstyleswpf-grid

Grid style in app.xaml makes content invisible


I want to define a grid style in the app.xaml, including the background color. However, setting the color there, makes the whole content instantly invisible.

enter image description here

When application is executed, the following appears:

enter image description here

For a short moment, the button is visible. How do I prevent this from happening, keeping in mind, that I wish a global background color for grids.


Solution

  • You can use a global style for the Grid as you have done it.

    The issue you have faced comes from Visual Studio. So the issue is only present, if you start the application via Visual Studio.

    To give the possibility for live tracking of UI-Elements the VS seems to add an AdornerLayerWindow, which, I suppose, also uses a Grid, which you see. You can find this window in Application.Current.Windows.

    To get rid of this behaviour you have to deactivate option Options->Debugging->UI-Tools for XAML activate