메뉴 건너뛰기

app

[WP7] 전역변수의 array(dicionary)와 map의 pushpin 제어하기

suritam92013.03.03 07:36조회 수 2198댓글 0

    • 글자 크기
아래와 같이 서브 함수에서 사용할 Dictionary 선언은 아래와 같다.

namespace blood_house
{
    public partial class MainPage : PhoneApplicationPage
    {
        public static Dictionary<string, string> bh = new Dictionary<string, string>
            {
       {"view", "뷰"},
       {"file", "files"},
       {"result", "results"},
       {"word", "words"},
       {"definition", "definitions"},
       {"item", "items"},
       {"megabyte", "megabytes"},
       {"game", "games"}
            };
~~~~~~~~~~~~~
}

푸시핀은 name과 content 를 property로 갖는다.
MouseLeftButtonUp 이벤트에 제어할 수 있는 함수를 할당하고, Name과 Contents를 sender as Pushpin 으로 받아,
Contents를 변경할 수 있다.

            Pushpin pin1 = new Pushpin();
            pin1.Location = mapCenter;
            pin1.Name = "view";
            pin1.MouseLeftButtonUp += new MouseButtonEventHandler(pin1_MouseLeftButtonUp);
            pin1.Content = "view";
            bloodMap.Children.Add(pin1);


아래와 같이 하면, pin의 content가 'view'와 '뷰'가 토글된다.

        void pin1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var pp = sender as Pushpin;
            int k = String.Compare(pp.Name, pp.Content.ToString());
            if (k==0)
            {
                pp.Content = bh[pp.Name];
            }
            else
            {
                pp.Content = pp.Name;
            }
            
        } 
suritam9 (비회원)
    • 글자 크기

댓글 달기

이전 1 ... 3 4 5 6 7 8 9 10 11 12... 14다음
첨부 (0)
위로