본문 바로가기
Silverlight와 WPF

Windows phone 7 에서 다른 버튼 클릭하기

by edupicker(체르니) 2011. 10. 5.
Windows Phone 7.1 Mango에서 하나의 버튼(Button)을 클릭하면 다른 버튼(Button)을 클릭하는 효과를 주기 위한 방법을 간략히 소개합니다.
기본적으로 Windows Forms에서 처리하는 방법과 거의 비슷합니다.

간단하게 Windows Phone 응용 프로그램 프로젝트를 생성하고 다음과 같이 Button 2개 TextBlock 컨트롤 1개를 도구 상자에서 끌어다 놓습니다.


 배치를 완료한 후  Button2, Button1를 클릭하여 다음과 같이 코드를 작성합니다.

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            button1_Click(this, e);
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            textBlock1.Foreground=new SolidColorBrush(Colors.Yellow);
            textBlock1.Text = "I'm a textBlock.^^";
        }

위와 같이 처리해주면 Button2를 클릭했을 때 Button1도 클릭되어 TextBlock의 텍스트를 노란색으로 표시하고 그 Text값을 다음과 같이 표시하게 됩니다.



간단하지만 모르면 어렵고 알면 쉬운 팁이었습니다. 모두들 즐플하세요.