gpt4 book ai didi

wpf - 为什么我的 xaml 只显示一个没有任何内容的普通窗口

转载 作者:可可西里 更新时间:2023-11-01 11:58:53 25 4
gpt4 key购买 nike

我是 WPF、Xaml 的新手,并且是 C# 初学者!我一直在研究这个,我不知道为什么下面的 xaml 只显示一个普通窗口。没有按钮,没有标题,没有内容。感谢您的指导。如果问我为什么必须使用 MediaChecker,我是按照 Stack Overflow 的以下帖子中的示例进行操作的:

How do i navigate from one Xaml file to another?

提前致谢。

<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 呈现得很好。如果您得到一个空白窗口,那么我怀疑它与其他原因有关,例如启动另一个窗口。

仔细检查正确的 Window正在 StartupUri 中启动你的属性(property)<Application>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>

关于wpf - 为什么我的 xaml 只显示一个没有任何内容的普通窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12148097/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com