问题
I am new to WPF, Xaml, and am a C# beginner! I have been working on this and I don't know why the following xaml just shows a plain window. No button, no title, no content. I would appreciate your guidance. If asking why I had to use MediaChecker I did it following an example from Stack Overflow's following post:
How do i navigate from one Xaml file to another?
Thanks in advance.
<Window x:Class="MediaCheckerWPF.AboutBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="About Media Checker" Height="300" Width="400" ResizeMode="NoResize"
ShowInTaskbar="False">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="Name:"/>
<Label Grid.Row="1" Grid.Column="0" Content="E-Mail:"/>
<Label Grid.Row="2" Grid.Column="0" Content="Comment:"/>
<Button Grid.Column="1" Grid.Row="0" HorizontalAlignment="Right"
MinWidth="80" Margin="3" Content="START" />
<Button Grid.Column="1" Grid.Row="3" HorizontalAlignment="Right"
MinWidth="80" Margin="3" Content="STOP" />
</Grid>
</Window>
回答1:
The XAML you have renders just fine. If you're getting a blank window then I suspect it has to do with something else, such as starting up a different Window.
Double-check that the correct Window
is starting up in the StartupUri property of your <Application>
tag in App.xaml
<Application x:Class="MediaCheckerWPF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="AboutBox.xaml">
<Application.Resources>
</Application.Resources>
</Application>
回答2:
Check the App.xaml for the StartupUri
<Application x:Class="GabeTexFilestImport.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
回答3:
I have noticed this happening also if system is very slow. Say, you are reaching max memory consumption which slows down your system. In that case, I have seen xaml windows showing up but completelly blank, no controls on it, no min, max, close buttons, no title.
来源:https://stackoverflow.com/questions/12148097/why-my-xaml-only-shows-a-plain-window-show-up-with-nothig-in-it