2

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.

Rekshino
  • 6,954
  • 2
  • 19
  • 44
Malior
  • 1,221
  • 8
  • 16
  • I just found another nearly same question here. https://stackoverflow.com/questions/52205414/my-wpf-ui-disappears-when-i-set-a-style-for-grid-in-app-xaml but answer is not really solving what is meant to achive – Malior Dec 18 '18 at 16:30
  • Do you really want to set global style for the grids? This mean, that it will be applied nearly everywhere, since `Grid` being used almost in each control template. Would be a work around, posted as comment in linked post, a solution for you? – Rekshino Dec 20 '18 at 15:01
  • I want to, as I want to make everything in kind of dark style, and switching between themes is morst easy over app.xaml. – Malior Dec 21 '18 at 06:58

1 Answers1

2

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

Rekshino
  • 6,954
  • 2
  • 19
  • 44