为什么我的 xaml 只显示一个没有显示的普通窗口 [英] Why my xaml only shows a plain window show up with nothig in it
问题描述
我是 WPF、Xaml 的新手,也是 C# 初学者!我一直在研究这个,我不知道为什么下面的 xaml 只显示一个普通的窗口.没有按钮,没有标题,没有内容.我将不胜感激您的指导.如果问我为什么必须使用 MediaChecker,我会按照 Stack Overflow 的以下帖子中的示例进行操作:
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:
提前致谢.
<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>
推荐答案
您拥有的 XAML 呈现得很好.如果你得到一个空白窗口,那么我怀疑它与其他事情有关,例如启动一个不同的窗口.
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.
再次检查 StartupUri 在 App.xaml
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>
这篇关于为什么我的 xaml 只显示一个没有显示的普通窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!