0
I had a form ready in my VS, After it was ready, I realized that I would need to add a Scrollbar. Searching and saw that to solve my problem was just add a Scrollviewer. When I add, my form gets all out of order, a label on one side and a textbox on the other. Because???
Help me =(
<Controls:MetroWindow x:Class="WpfSistemaDinamCorp.Telas.CadastroEmpresa"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
Title="Cadastro de Empresa" Height="1081" Width="1400" WindowState="Maximized" UseLayoutRounding="False" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto">
<Grid Margin="0,0,18,21" UseLayoutRounding="False" ScrollViewer.CanContentScroll="True">
<Grid.RowDefinitions>
<RowDefinition Height="4*"/>
<RowDefinition Height="45*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Auto" Margin="0,0,0,52" Grid.RowSpan="2">
<StackPanel>
<Label Content="CADASTRO DE EMPRESA" VerticalAlignment="Top" Height="43" Width="302" FontSize="24" HorizontalAlignment="Center" Margin="528,0,544,0"/>
<Label Content="Código:" HorizontalAlignment="Left" Margin="77,2,0,0" VerticalAlignment="Top" Grid.Row="1"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="133,3,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="190" Grid.Row="1"/>
<Label Content="CNPJ / CPF:" HorizontalAlignment="Left" Margin="60,33,0,0" VerticalAlignment="Top" Grid.Row="1"/>
<Label Content="Razão Social / Nome:" HorizontalAlignment="Left" Margin="9,64,0,0" VerticalAlignment="Top" Grid.Row="1"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="133,34,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="190" Grid.Row="1"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="133,65,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="559" Grid.Row="1"/>
<Label Content="Nome Fantasia:" HorizontalAlignment="Left" Margin="39,121,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="133,121,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="290"/>
<Label Content="CEP:" HorizontalAlignment="Left" Margin="98,152,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="133,152,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="158"/>
<Label Content="Código IBGE:" HorizontalAlignment="Left" Margin="52,184,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="133,183,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="158"/>
<Label Content="Tipo de Logradouro:" HorizontalAlignment="Left" Margin="13,215,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="133,215,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="158"/>
<Label Content="Inscrição Estadual:" HorizontalAlignment="Left" Margin="25,246,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<Label Content="Inscrição Municipal:" HorizontalAlignment="Left" Margin="17,278,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<Label Content="RNTRC:" HorizontalAlignment="Left" Margin="81,309,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="133,246,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="190"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="133,278,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="190"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="133,309,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="190"/>
<Label Content="Apelido:" HorizontalAlignment="Left" Margin="474,121,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="528,121,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="240"/>
<Label Content="Site:" HorizontalAlignment="Left" Margin="819,121,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="851,121,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="244"/>
<Label Content="Município:" HorizontalAlignment="Left" Margin="355,184,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="425,183,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="210"/>
<Label Content="Bairro:" HorizontalAlignment="Left" Margin="693,184,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="742,183,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="180"/>
<Label Content="Estado (UF):" HorizontalAlignment="Left" Margin="967,183,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="1045,183,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="50"/>
<Label Content="Logradouro:" HorizontalAlignment="Left" Margin="348,215,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<Label Content="Número:" HorizontalAlignment="Left" Margin="681,215,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<Label Content="Complemento:" HorizontalAlignment="Left" Margin="906,216,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="425,216,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="210"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="742,216,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="999,216,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="96"/>
<Label Content="Cód. Serv.:" HorizontalAlignment="Left" Margin="405,246,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<Label Content="Cód. Ativ.:" HorizontalAlignment="Left" Margin="675,246,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<Label Content="Regime Trib.:" HorizontalAlignment="Left" Margin="391,278,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<Label Content="Tipo de Empresa:" HorizontalAlignment="Left" Margin="369,309,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="474,247,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="161"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="742,247,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="353"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="475,278,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="620"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="475,309,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="620"/>
<Label Content="CNAE - Classificação Nacional de Atividades Econômicas" HorizontalAlignment="Left" Margin="130,336,0,0" Grid.Row="1" VerticalAlignment="Top" FontWeight="Bold"/>
<Label Content="Código:" HorizontalAlignment="Left" Margin="79,362,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<Label Content="Descrição:" HorizontalAlignment="Left" Margin="320,362,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="133,362,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="389,362,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="605"/>
<Button Content="Adicionar" HorizontalAlignment="Left" Margin="1006,362,0,0" Grid.Row="1" VerticalAlignment="Top" Width="90 "/>
<DataGrid HorizontalAlignment="Left" Margin="133,393,0,0" Grid.Row="1" VerticalAlignment="Top" Width="962" Height="60"/>
<Label Content="Descrição da Atividade:" HorizontalAlignment="Left" Margin="-2,456,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="130,456,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="965"/>
<Label Content="Contatos" HorizontalAlignment="Left" Margin="126,483,0,0" Grid.Row="1" VerticalAlignment="Top" FontWeight="Bold"/>
<Label Content="E-mail:" HorizontalAlignment="Left" Margin="82,509,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="130,510,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="350"/>
<Label Content="Observação:" HorizontalAlignment="Left" Margin="517,509,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="597,510,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="397"/>
<Button Content="Adicionar" HorizontalAlignment="Left" Margin="1006,510,0,0" Grid.Row="1" VerticalAlignment="Top" Width="90"/>
<DataGrid HorizontalAlignment="Left" Margin="130,541,0,0" Grid.Row="1" VerticalAlignment="Top" Width="965" Height="60"/>
<Label Content="Prefixo (99):" HorizontalAlignment="Left" Margin="56,606,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<Label Content="Telefone:" HorizontalAlignment="Left" Margin="233,606,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<Label Content="Observação:" HorizontalAlignment="Left" Margin="580,606,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="130,607,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="70"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="296,607,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="250"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="660,607,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="334"/>
<Button Content="Button" HorizontalAlignment="Left" Margin="1006,606,0,0" Grid.Row="1" VerticalAlignment="Top" Width="90"/>
<DataGrid HorizontalAlignment="Left" Margin="130,638,0,0" Grid.Row="1" VerticalAlignment="Top" Width="965" Height="58"/>
<Button Content="Salvar" HorizontalAlignment="Left" Margin="133,731,0,0" Grid.Row="1" VerticalAlignment="Top" Width="92"/>
</StackPanel>
</ScrollViewer>
</Grid>
Can you give me an example of how to do that? Because before I put this Stackpanel, it was all okay. And I put it on myself just so I could have a Scroll...
– Emerson Moraes
I edited the answer.
– ramaral
Thanks again Ramaral. You are a genius! xD
– Emerson Moraes