button 1 private void button 1Clickobject sender Event
이벤트 처리 함수 // button 1이 클릭될 때 발생하는 이벤트처리함수 private void button 1_Click(object sender, Event. Args e) { if (text. Box 1. Text == "의료IT" && text. Box 2. Text == "1234") { label 3. Text = "성공했습니다"; } else { label 3. Text = "실패했습니다"; } }
2주차 1일 3. 7(화) Form : Login – Close() WPF : Hello. World / BMI계산기
배경색과 글자색을 Toggle private void label 1_Click(object sender, Event. Args e) { if (label 1. Fore. Color != Color. White) { label 1. Fore. Color = Color. White; this. Back. Color = Color. Black; } else { label 1. Fore. Color = Label. Default. Fore. Color; this. Back. Color = Form. Default. Back. Color; } }
2. WPF Hello. World <Grid> <Label Name="label 1" Horizontal. Alignment="Center" Vertical. Alignment="Center" Font. Size="30" Font. Weight="Bold" Mouse. Down="Label_Mouse. Down">Hello World!</Label> </Grid> // Form 에서는 클릭이었지만, WPF에서는 Mouse. Down private void Label_Mouse. Down(object sender, Mouse. Button. Event. Args e) { if(label 1. Foreground != Brushes. White) { label 1. Foreground = Brushes. White; this. Background = Brushes. Blue; } else { label 1. Foreground = System. Colors. Window. Text. Brush; this. Background = System. Colors. Window. Brush; } }
WPF Grid Label Text. Block Stack. Panel 위에서부터 컨트롤들을 쌓아나간다 Stack. Panel 안에 Stack. Panel이 또 있을 수 있다 Orientation=“Horizontal”
- Slides: 25