WPF网格未显示

WPF网格未显示,wpf,visual-studio,user-interface,Wpf,Visual Studio,User Interface,它应该是什么样子 它看起来像什么 所以我不知道为什么它没有显示顶部, 有人能帮忙吗? 我无法解释更多。因为我不知道该做什么,我 不知道该怎么解决。我在WPF上看过的视频 他们真的很糟糕,我不能理解他们 <Window x:Class="EasyMath.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsof

它应该是什么样子

它看起来像什么

所以我不知道为什么它没有显示顶部, 有人能帮忙吗? 我无法解释更多。因为我不知道该做什么,我 不知道该怎么解决。我在WPF上看过的视频 他们真的很糟糕,我不能理解他们

<Window x:Class="EasyMath.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:EasyMath"
    mc:Ignorable="d"
    Title="Easy Math" Height="450" Width="580.96" Icon="Icon.png" ResizeMode="CanMinimize" Background="#FF2F3542" Foreground="Black" WindowStyle="None">
<Grid Margin="0,-45,0,0">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="151*"/>
        <ColumnDefinition Width="430*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="41*"/>
        <RowDefinition Height="409*"/>
    </Grid.RowDefinitions>
    <Grid Grid.ColumnSpan="2" Background="#FF2F3542" Margin="-1,0,0,10">
        <Button x:Name="QuitApp" Content="Button" Margin="550,5,6,5" Background="#FFFF4757" BorderBrush="{x:Null}" Foreground="{x:Null}" Click="QuitApplication"/>
        <Button Content="Button" Margin="520,5,37,5" Background="#FFFFA502" BorderBrush="{x:Null}" Foreground="{x:Null}"/>
        <Button Content="Button" Margin="489,5,67,5" Background="#FF2ED573" BorderBrush="{x:Null}" Foreground="{x:Null}" Click="Button_Click"/>
    </Grid>
    <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Easy Math" VerticalAlignment="Top" Foreground="White" Height="35" Width="112" FontSize="24" Margin="10,-2,0,0"/>
</Grid>


从根网格边距中删除-45。这样,您就可以说根网格应该向上缩进45像素,从而有效地隐藏标题栏

事实上,您可以从根网格中完全删除边距

编辑:

看看你的素描,这可能是你要找的东西

<Window x:Class="Test.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Easy Math"
        WindowStartupLocation="CenterScreen" 
        ResizeMode="CanMinimize" AllowsTransparency="True" 
        Background="Transparent" 
        WindowStyle="None">
    <Window.Resources>
        <Style TargetType="Button" x:Key="titleBarButton">
            <Setter Property="Width" Value="25"/>
            <Setter Property="Height" Value="25"/>
            <Setter Property="BorderBrush" Value="{x:Null}"/>
            <Setter Property="Foreground" Value="{x:Null}"/>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Background="#FF2F3542">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Easy Math" VerticalAlignment="Top" Foreground="White" FontSize="24" Margin="10,0,0,0"/>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0">
                <Button Style="{StaticResource titleBarButton}" Background="#FF2ED573"/>
                <Button Style="{StaticResource titleBarButton}" Background="#FFFFA502"/>
                <Button Style="{StaticResource titleBarButton}" Background="#FFFF4757"/>
            </StackPanel>
        </Grid>
        <Grid Grid.Row="1" Height="10" Background="Transparent"/>
        <Grid Grid.Row="2" Background="#FF2F3542">
        </Grid>
    </Grid>
</Window>


请共享一些代码,如果没有其他信息,我们将无法帮助您。我已添加了代码。请将网格边距-45替换为0,但我希望它具有该空间。我会很快加上我的素描。看来你不明白边距是干什么的。我建议你仔细阅读一下。此外,如果您查看VisualStudio XAML设计,您将看到可见区域是什么。它由一个蓝色边框表示,它清楚地表明标题栏将不可见。我注意到的另一件事是,您可能来自WinForms后台,正在尝试“使用”设计器。这不是WPF的方式。您应该使用XAML。“这不是WPF的方式”——奇怪的说法。它只是wpf设计器比winforms差(或者说本身不差,但不支持大量可用的布局选项),这肯定不是我使用wpf开发的方式。如果你拖放控件,那么你很可能会得到较大的固定边距,并且你的应用程序可能只在与显示器大小设置匹配的机器上按预期工作。