简体   繁体   English

在WPF中调整窗口

[英]Adjust Window in WPF

I'm starting with a development in WPF and C # I've learned some things since I come from Windows Forms but I've run into a case that is not how to solve, I thank my guide. 我从WPF和C的开发入手。自从Windows Forms以来,我已经学到了一些东西,但是遇到了一个无法解决的问题,感谢指导。

I get the following window menu through a call to a user control and paint it in a frame but looks like. 我通过调用用户控件得到以下窗口菜单,并将其绘制在框架中,但是看起来像。

形成

You see the User control is above the additional menu to maximize the form remains the same, you know as I can solve ?? 您会看到User控件上方的附加菜单最大程度地保持了窗体不变,您知道可以解决吗?

This is the XAML of the main window. 这是主窗口的XAML。

<controls:MetroWindow x:Class="Laboratorio.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:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    mc:Ignorable="d"
    Title="Sistema de Control y Gestion de Laboratorio" 
    Height="650" Width="825"
    BorderThickness="0"    
    GlowBrush="Black"
    ResizeMode="CanResizeWithGrip"
    WindowTransitionsEnabled="False"
    Loaded="MainWindow_OnLoaded"
    WindowStartupLocation="CenterScreen">
<!-- Menu -->
<Grid>
    <Menu Name="MenuPrincipal">

    </Menu>
    <Frame Name="Contenido"></Frame>
</Grid>

and this the the user control 这是用户控制的

<UserControl x:Class="Laboratorio.RegistroEquipo"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         Loaded="RegistroEquipo_OnLoaded"
         mc:Ignorable="d" 
         d:DesignHeight="450" d:DesignWidth="545">
<Grid>
    <GroupBox Header="Registro de Equipo">
        <Grid>
            <Label x:Name="serialLbl" Content="Serial:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
            <TextBox x:Name="serialTxb" HorizontalAlignment="Left" Height="23" Margin="89,11,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="140"/>
            <Label x:Name="descripcionLbl" Content="Descripcion:" HorizontalAlignment="Left" Margin="263,11,0,0" VerticalAlignment="Top"/>
            <TextBox x:Name="descripcionTxb" HorizontalAlignment="Left" Height="23" Margin="362,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="140"/>
            <Label x:Name="marcaLbl" Content="Marca:" HorizontalAlignment="Left" Margin="10,49,0,0" VerticalAlignment="Top"/>
            <ComboBox x:Name="marcaCbb" HorizontalAlignment="Left" VerticalAlignment="Top" Width="140" Margin="89,49,0,0"/>
            <Label x:Name="claseLbl" Content="Clase:" HorizontalAlignment="Left" Margin="263,49,0,0" VerticalAlignment="Top"/>
            <TextBox x:Name="claseTxb" HorizontalAlignment="Left" Height="23" Margin="362,49,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="140"/>
            <CheckBox x:Name="externoChk" Content="Externo" HorizontalAlignment="Left" Margin="10,91,0,0" VerticalAlignment="Top"/>
            <CheckBox x:Name="patronchk" Content="Patron" HorizontalAlignment="Left" Margin="171,91,0,0" VerticalAlignment="Top"/>
            <Label x:Name="articuloLbl" Content="Articulo:" HorizontalAlignment="Left" Margin="263,87,0,0" VerticalAlignment="Top"/>
            <TextBox x:Name="articuloTxb" HorizontalAlignment="Left" Height="23" Margin="362,87,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="140"/>
            <Label x:Name="articuloLbl_Copy1" Content="Responsable:" HorizontalAlignment="Left" Margin="10,127,0,0" VerticalAlignment="Top"/>
            <TextBox x:Name="responsableTxb" HorizontalAlignment="Left" Height="23" Margin="89,127,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="140"/>
            <TextBox x:Name="nombreTxb" HorizontalAlignment="Left" Height="23" Margin="263,127,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="239"/>
            <Label x:Name="observacionLbl" Content="Observacion:" HorizontalAlignment="Left" Margin="10,175,0,0" VerticalAlignment="Top"/>
            <TextBox x:Name="observacionTxb" HorizontalAlignment="Left" Height="79" Margin="10,223,0,0" TextWrapping="Wrap" AcceptsReturn="True" VerticalAlignment="Top" Width="503"/>
            <Button x:Name="registrarBtn" Content="Registrar" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="154,338,0,0" Click="Registrar_OnClick"/>
            <Button x:Name="salirBtn" Content="Salir" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="263,338,0,0"/>
        </Grid>
    </GroupBox>
</Grid>

Turn this; 转这个;

<!-- Menu -->
<Grid>
    <Menu Name="MenuPrincipal">

    </Menu>
    <Frame Name="Contenido"></Frame>
</Grid>

into this; 进入这个

<!-- Menu -->
<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="*"/>
  </Grid.RowDefinitions>

    <Menu Name="MenuPrincipal"/>
    <Frame Grid.Row="1" Name="Contenido"/>

</Grid>

Or just swap Grid for StackPanel whichever you prefer. 或者,只要您愿意,就可以将Grid交换为StackPanel

It's not your application/xaml, it's a Visual Studio tool used for debugging. 这不是您的application / xaml,而是用于调试的Visual Studio工具。

When your application is running, go back to Visual Studio, go to the Live Visual Tree, and you can turn off "Show runtime tools in application" (the first button in the toolbar) 当您的应用程序运行时,返回到Visual Studio,转到“实时可视树”,然后可以关闭“在应用程序中显示运行时工具”(工具栏中的第一个按钮)

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM