1

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

如何从一个 Xaml 文件导航到另一个 Xaml 文件?

提前致谢。

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

3 回答 3

1

检查 App.xaml 中的 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>
于 2012-08-27T20:21:43.427 回答
1

您拥有的 XAML 渲染得很好。如果你得到一个空白窗口,那么我怀疑它与其他事情有关,例如启动一个不同的窗口。

仔细检查您的标签的StartupUri属性是否正确Window启动<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>
于 2012-08-28T02:20:19.560 回答
0

如果系统非常慢,我也注意到会发生这种情况。比如说,您正在达到最大内存消耗,这会减慢您的系统。在这种情况下,我看到 xaml 窗口出现但完全空白,没有控件,没有最小值,最大值,关闭按钮,没有标题。

于 2016-08-18T18:29:56.200 回答