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

时间:2012-08-27 19:11:59

标签: wpf windows visual-studio-2010 xaml

我是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> 

3 个答案:

答案 0 :(得分: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>

答案 1 :(得分:1)

您渲染的XAML就好了。如果你得到一个空白窗口,那么我怀疑它与其他东西有关,比如启动一个不同的窗口。

仔细检查Window

<Application>标记的StartupUri属性中是否启动了正确的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 :(得分:0)

如果系统非常慢,我也注意到了这种情况。比如,您达到最大内存消耗,这会降低系统速度。在这种情况下,我看到xaml窗口显示但完全空白,没有控件,没有最小,最大,关闭按钮,没有标题。