티스토리 뷰
Grid, StackPanel, CheckBox, TextBlock, TextBox 등 컨트롤들과 패널들을 이용한 UI 제작
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | <Window x:Class="WpfBasics.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:local="clr-namespace:WpfBasics" mc:Ignorable="d" Loaded="Window_Loaded" Title="WPF Basics" Height="800" Width="400"> <!--36:00--> <Border Padding="10"> <StackPanel> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="1*"></ColumnDefinition> <ColumnDefinition Width="1*"></ColumnDefinition> <ColumnDefinition Width="1*"></ColumnDefinition> </Grid.ColumnDefinitions> <Button x:Name="ApplyButtonq" Click="ApplyButtonq_Click" Grid.Column="0" Content= "Apply" Margin="10"></Button> <Button x:Name="RessetButton" Click="RessetButton_Click" Grid.Column="1" Content="Reset" Margin="10"></Button> <Button Grid.Column="2" Content="Refresh" Margin="10"></Button> </Grid> <TextBlock Text="Pulse Properties" FontWeight="Bold" Margin="0 10"></TextBlock> <!--Description--> <TextBlock Text="Description"></TextBlock> <TextBox x:Name="DescriptionText" Padding="5"></TextBox> <!--Padding은 내부, Margin은 외부--> <!--Status and Revision--> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="2*"></ColumnDefinition> <ColumnDefinition Width="1*"></ColumnDefinition> </Grid.ColumnDefinitions> <StackPanel Grid.Column="0" Margin="0 0 10 0"> <TextBlock Text="Status"></TextBlock> <TextBox Padding="2" IsReadOnly="True" Background="#eeeeee" ></TextBox> </StackPanel> <StackPanel Grid.Column="1" Margin="0 0 0 0"> <TextBlock Text="Revision"></TextBlock> <TextBox Padding="2" IsReadOnly="True" Background="#eeeeee" ></TextBox> </StackPanel> </Grid> <!--Part Number--> <TextBlock Text="Part Number"></TextBlock> <TextBox IsReadOnly="True" Background="#eee" Padding="2"></TextBox> <TextBlock Text="Rwa Material" FontWeight="Bold" Margin="0 10"></TextBlock> <!--Material--> <TextBlock Text="Material"></TextBlock> <ComboBox IsReadOnly="True" Background="#eee"></ComboBox> <TextBlock Text="Manufacturing Information" FontWeight="Bold" Margin="0 10"></TextBlock> <TextBlock Text="Work Centres"></TextBlock> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="1*"></ColumnDefinition> <ColumnDefinition Width="1*"></ColumnDefinition> </Grid.ColumnDefinitions> <StackPanel Grid.Column="0"> <CheckBox Checked="Checkbox_Checked" x:Name="WeldCheckbox" Content="Weld"></CheckBox> <CheckBox Checked="Checkbox_Checked" x:Name="AssemblyCheckbox" Content="Assembly"></CheckBox> <CheckBox Checked="Checkbox_Checked" x:Name="PlasmaCheckbox" Content="Plasma"></CheckBox> <CheckBox Checked="Checkbox_Checked" x:Name="LaserCheckbox" Content="Laser"></CheckBox> <CheckBox Checked="Checkbox_Checked" x:Name="PurchaseCheckbox" Content="Purchase"></CheckBox> </StackPanel> <!--[Alt]+드래그 하면 세로로 선택이 가능--> <StackPanel Grid.Column="1"> <CheckBox Checked="Checkbox_Checked" x:Name="LatheCheckbox" Content="Lathe"></CheckBox> <CheckBox Checked="Checkbox_Checked" x:Name="DrillCheckbox" Content="Drill"></CheckBox> <CheckBox Checked="Checkbox_Checked" x:Name="FoldCheckbox" Content="Fold"></CheckBox> <CheckBox Checked="Checkbox_Checked" x:Name="RollCheckbox" Content="Roll"></CheckBox> <CheckBox Checked="Checkbox_Checked" x:Name="SawCheckbox" Content="Saw"></CheckBox> </StackPanel> </Grid> <!--Length--> <TextBlock Text="Length"></TextBlock> <TextBox x:Name="LengthText" Padding="2"></TextBox> <!--Mass--> <TextBlock Text="Mass"></TextBlock> <TextBox x:Name="MassText" Padding="2" IsReadOnly="True" Background="#eee"></TextBox> <!--Finish--> <TextBlock Text="Finish"></TextBlock> <ComboBox x:Name="FinishiDropdown" SelectionChanged="FinishiDropdown_SelectionChanged" Padding="2" SelectedIndex="0"> <ComboBoxItem>Painted</ComboBoxItem> <ComboBoxItem>Not Painted</ComboBoxItem> </ComboBox> <!--Purchase Info--> <TextBlock Text="Purchase Info"></TextBlock> <ComboBox Padding="2" SelectedIndex="0"> <ComboBoxItem>Rubber</ComboBoxItem> <ComboBoxItem>Not Rubber</ComboBoxItem> </ComboBox> <!--Supplier Name--> <TextBlock Text="Supplier Name"></TextBlock> <TextBox Padding="2"></TextBox> <!--Supplier Code--> <TextBlock Text="Supplier Code"></TextBlock> <TextBox x:Name="SupplierNameText" TextChanged="SupplierNameText_TextChanged" Padding="2"></TextBox> <TextBlock Text="Additional Info" FontWeight="Bold" Margin="0 10"></TextBlock> <TextBlock Text="Note"></TextBlock> <TextBox x:Name="NoteText" Padding="2"></TextBox> </StackPanel> </Border> </Window> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | 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 WpfBasics { /// <summary> /// MainWindow.xaml에 대한 상호 작용 논리 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void ApplyButtonq_Click(object sender, RoutedEventArgs e) { MessageBox.Show($"The description is : {this.DescriptionText.Text}"); } private void RessetButton_Click(object sender, RoutedEventArgs e) { this.WeldCheckbox.IsChecked = this.AssemblyCheckbox.IsChecked = this.PlasmaCheckbox.IsChecked = this.LaserCheckbox.IsChecked = this.PurchaseCheckbox.IsChecked = this.LatheCheckbox.IsChecked = this.DrillCheckbox.IsChecked = this.FoldCheckbox.IsChecked = this.RollCheckbox.IsChecked = false; } private void Checkbox_Checked(object sender, RoutedEventArgs e) { this.LengthText.Text += (string)((CheckBox)sender).Content + ", "; } private void FinishiDropdown_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.NoteText == null) return; var combo = (ComboBox)sender; var value = (ComboBoxItem)combo.SelectedValue; this.NoteText.Text = (string)value.Content; } private void Window_Loaded(object sender, RoutedEventArgs e) { FinishiDropdown_SelectionChanged(this.FinishiDropdown, null); } private void SupplierNameText_TextChanged(object sender, TextChangedEventArgs e) { this.MassText.Text += this.SupplierNameText.Text; } } } | cs |
'C# > WPF' 카테고리의 다른 글
WPF tutorial - The StringFormat property (0) | 2017.06.25 |
---|---|
WPF tutorial - Value conversion with IValueConverter (1) | 2017.06.25 |
WPF tutorial - Responding to changes (0) | 2017.06.22 |
WPF tutorial - Using the DataContext, The UpdateSourceTrigger property (0) | 2017.06.22 |
WPF tutorial - Introduction to WPF data binding (0) | 2017.06.22 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 스택
- Fakebook
- command
- 백준
- CustomCollectionViewCell
- C++
- 코딩야학
- UIView Animation
- 데이터 바인딩
- BOJ
- Custom Cell
- WPF
- DP
- 객체
- 타일링
- MVVM
- dfs
- FEED
- 백준온라인
- listview
- XAML
- Grid
- 문자열
- 생활코딩
- Cell Animation
- 그래프
- BFS
- CollectionView
- Add TapGesture
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
글 보관함