Cristian
Cristian

Reputation: 301

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.

I get the following window menu through a call to a user control and paint it in a frame but looks like.

Form

You see the User control is above the additional menu to maximize the form remains the same, you know as I can solve ??

This is the XAML of the main window.

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

Upvotes: 0

Views: 488

Answers (2)

Chris W.
Chris W.

Reputation: 23270

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.

Upvotes: 2

sfm
sfm

Reputation: 613

It's not your application/xaml, it's a Visual Studio tool used for debugging.

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)

enter image description here

Upvotes: 1

Related Questions