WPF Grid не отображается - PullRequest
       7

WPF Grid не отображается

0 голосов
/ 27 февраля 2020

Мой эскиз

Как это должно выглядеть

What it should look like

Как это выглядит

What it looks like

Так что я не уверен, почему он не показывает верх, кто-то может помочь? и я не могу объяснить больше. Потому что я не знаю, что делать, и я не уверен, что это нужно исправить. Видео, которые я смотрел на 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>

1 Ответ

0 голосов
/ 27 февраля 2020

Удалите -45 из root Сетка. При этом вы говорите, что сетка root должна отступать сверху для 45 пикселей, эффективно скрывая строку заголовка.

На самом деле вы можете полностью удалить маржу из сетки root.

РЕДАКТИРОВАТЬ:

Глядя на свой эскиз, это может быть то, что вы можете искать .

<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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...