0

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>

1
  • I don't see where you have created an instance of RegistroEquipo in your MainWindow.xaml. My guess it that it is related to placing a Menu and Frame inside of a Grid, and the Grid is stacking the objects on top of each other (assuming this is where you connect your UserControl. Commented May 24, 2016 at 15:46

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you, Just what you tell me solve the problem. Let me get in "RowDefinition" 2 lines are added referring to the menu and the frame?
Ya you're just defining the number of rows your Grid contains. Otherwise it will just stack it's children on top of one another according to their z-index. When you add Grid.Row="1" to the second object you're declaring it belongs in the 2nd row of your Grid because the row count begins at 0. So 0 is first row, 1 is second row, etc, etc...
No worries, pay it forward to someone else some day. Cheers :)
1

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

3 Comments

Thanks @sfm, I mean the menu of the application, the "group box" is above the menu, and edit the image.
Ah, sorry I didn't catch that. Ignore this answer.
That's still a damn handy tip though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.