<Window x:Class="WpfHelloWorld.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 Height="30"></RowDefinition> <RowDefinition Height="*"></RowDefinition> <RowDefinition Height="30"></RowDefinition> </Grid.RowDefinitions> <TextBox Name="txtMessage" Grid.Row="0" Margin="5, 5, 5, 5" /> <Button Name="btnOK" Content="확인" Grid.Row="2" /> </Grid> </Window> |
2. 디자인 모드에서 F7 코드 비하인드 페이지에서 다음과 같이 이벤트를 추가하여 준다
using System; using System.Collections.Generic; using System.Linq; using System.Text; 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 WpfHelloWorld { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); btnOK.Click += new RoutedEventHandler(btnOK_Click); } void btnOK_Click(object sender, RoutedEventArgs e) { MessageBox.Show(txtMessage.Text); } } } |
3. 결과 화면 입니다...
MessageBox.Show ("텍스트박스내용")
을 다음과 같이 출력해주고 있습니다..
'.Net Project > WPF' 카테고리의 다른 글
06. WPF AddressBook 주소록 간단 출력 응용 프로그램 작성 (0) | 2010.05.21 |
---|---|
05. WPF Windows 바탕화면 변경하기 (0) | 2010.05.21 |
04. WPF PatientReferrals (0) | 2010.05.21 |
03. WPF 웹 브라우저 실행하여 날짜값 출력 (0) | 2010.05.21 |
01. WPF 시작하기 (0) | 2010.05.21 |