I have a window with a grid containing an image and some buttons:
<Window x:Class="Wormholes.Views.TitleWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Wormholes"
xmlns:commands="clr-namespace:Wormholes.Commands"
mc:Ignorable="d"
Title="Warning: Weird Wormholes!" Height="450" Width="800" WindowState="Maximized" WindowStyle="None">xi
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="64"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image Source="/Images/Splash.png" Grid.RowSpan="2" Grid.ColumnSpan="3"/>
<Button Grid.Row="1" Grid.Column="0" Command="commands:Commands.StartCommand">Start</Button>
<Button Grid.Row="1" Grid.Column="2" Command="commands:Commands.ExitCommand">Exit</Button>
</Grid>
</Window>
And a style in App.xaml:
<Application x:Class="Wormholes.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Wormholes"
StartupUri="Views/TitleWindow.xaml">
<Application.Resources>
<Style TargetType="{x:Type Grid}">
<Setter Property="Background" Value="Black"/>
</Style>
</Application.Resources>
</Application>
However when this style exists in App.xaml, then when I run my app, the image and buttons disappear as soon as the window opens! If I delete the style, the controls appear (unstyled of course). and if I put the style in Window.Resources
, it works, but of course then it wouldn't apply to any other views I created. How can I make the style work from App.xaml?