FILE -> NEW -> Project -> WPF 애플리케이션
프로젝트명 : HelloWorld1
솔루션 탐색기에서 MainWindow.xaml 파일 클릭
왼쪽 바에서 도구상자 클릭
Lable
, TextBox
, Button
, TextBlock
을 xaml파일로 드래그 하기 F4
를 눌러 속성 변경(Content 변경하여 속성명을 변경 가능)선택요소의 이벤트 처리기
) 클릭수행 화면
MessageBox.Show(textBox.Text+"님 안녕하세요.","Hello World");
MessageBox.Show("Hi, there!", "Hello World", MessageBoxButton.OK, MessageBoxImage.Information);
xaml
<Window x:Class="HelloWorld1.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:HelloWorld1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Label Content="Enter a Name?" HorizontalAlignment="Left" Margin="151,104,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.596,-1.501"/>
<Button Content="Click me" HorizontalAlignment="Left" Margin="472,109,0,0" VerticalAlignment="Top" Click="Button_Click"/>
<TextBlock HorizontalAlignment="Left" Margin="302,155,0,0" Text="Hello World i am Click" TextWrapping="Wrap" VerticalAlignment="Top" Width="179" MouseLeftButtonUp="TextBlock_MouseLeftButtonUp"/>
<TextBox HorizontalAlignment="Left" Margin="316,110,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" TextChanged="TextBox_TextChanged"/>
</Grid>
</Window>
using System.Windows;
using System.Windows.Input;
namespace HelloWorld1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(textBox.Text+"님 안녕하세요.","Hello World");
}
private void textBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Hi, there!", "Hello World", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}