Image and button controls disappear from WPF window at runtime when style is applied

I have this XAML for a window:

<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"> <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> 

However when I run my app, the image and buttons appear briefly, then disappear, and I’m left with a blank window.

I have a style in App.xaml:

<Style TargetType="{x:Type Grid}"> <Setter Property="Background" Value="Black"/> </Style> 

If I delete this style, the image and buttons remain onscreen; however the background is white, and I want it to be black. Why are my controls disappearing when the style is present, and how can I prevent this from happening? Thanks! 🙂

submitted by /u/ekolis
[link] [comments]

Leave a Reply