Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>>>Tela WPF<<<<
- <Window
- x:Class="MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="MainWindow"
- Height="350"
- Width="525">
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition />
- <RowDefinition />
- <RowDefinition />
- <RowDefinition />
- <RowDefinition />
- <RowDefinition />
- </Grid.RowDefinitions>
- <Grid.ColumnDefinitions>
- <ColumnDefinition
- Width="*" />
- <ColumnDefinition
- Width="3*" />
- </Grid.ColumnDefinitions>
- <Button Content="Gravar"
- Grid.Column="1"
- HorizontalAlignment="Left"
- VerticalAlignment="Top"
- Width="75"
- Grid.Row="5"
- Name="btnGravar"
- Click="btnGravar_Click"/>
- <Label
- Content="Nome"
- HorizontalAlignment="Right"
- VerticalAlignment="Center"
- />
- <Label
- Content="Sexo"
- HorizontalAlignment="Right"
- VerticalAlignment="Center"
- Grid.Row="1" />
- <Label
- Content="Estado civil"
- HorizontalAlignment="Right"
- VerticalAlignment="Center"
- Grid.Row="2" />
- <Label
- Content="Data de Nascimento"
- HorizontalAlignment="Right"
- VerticalAlignment="Center"
- Grid.Row="3" />
- <Label
- Content="Hobies"
- HorizontalAlignment="Right"
- VerticalAlignment="Center"
- Grid.Row="4" />
- <TextBox
- Grid.Column="1"
- Margin="0 10 30 0"
- Name="txtNome"/>
- <StackPanel Grid.Column="1"
- Grid.Row="1"
- Orientation="Horizontal"
- Margin="0 10 30 10"
- VerticalAlignment="Center">
- <RadioButton Content="Masculino"
- Margin="0 0 10 0"/>
- <RadioButton
- Content="Feminino"
- Margin="0 0 10 0" />
- </StackPanel>
- <ComboBox Grid.Column="1"
- Grid.Row="2"
- Margin="0 10 30 10">
- <ComboBoxItem Content="Selecione"
- IsSelected="True" />
- <ComboBoxItem Content="Casado" />
- <ComboBoxItem Content="Solteiro" />
- </ComboBox>
- <DatePicker
- Grid.Column="1"
- Grid.Row="3"
- Margin="0 10 30 10"
- Name="dtpNascimento"/>
- <StackPanel
- Grid.Column="1"
- Grid.Row="4"
- Margin="0 10 30 10" />
- <StackPanel
- Grid.Column="1"
- Grid.Row="4"
- Orientation="Horizontal"
- VerticalAlignment="Center">
- <CheckBox Margin="0 0 15 0" Content="Caminhar"
- Name="chkCaminhar"/>
- <CheckBox Margin="0 0 15 0" Content="Ler"
- Name="chkLer"/>
- <CheckBox Margin="0 0 15 0" Content="Pasear"
- Name="chkPassear"/>
- </StackPanel>
- </Grid>
- </Window>
- >>>Main<<<
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace ControleWPF
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- private void btnGravar_Click(object sender, RoutedEventArgs e)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append("Nome" + txtNome.Text + "\n\n");
- string sexo = (bool)radMasculino.IsChecked ? "Masculino" : "Feminino";
- sb.Append("Sexo" + sexo);
- string estadoCivil = CboCasado.IsSelected ? "Casado" : "Solteiro";
- sb.Append("Estado Civil" + estadoCivil);
- DateTime dataNascimento = (DateTime)dtpNascimento.SelectedDate;
- sb.Append("Data de nascimento" + dataNascimento.ToShortDateString() + "\n\n");
- string hobbies = (bool)chkCaminhar.IsChecked ? "Caminhar" : "";
- hobbies += (bool)chkLer.IsChecked ? ", Ler" : "";
- hobbies += (bool)chkPassear.IsChecked ? ", Passear" : "";
- sb.Append("Hobbies: " + hobbies);
- MessageBox.Show(sb.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement