메뉴 건너뛰기

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 (비회원)
    • 글자 크기
[WP7] 앱 설정 tip 2가지와 현재 위치 가져오기 (by suritam9) [풀이] 머리가 굳었을 때 풀어보는 문제 (by suritam9)

댓글 달기

suritam9
2013.04.25 조회 5851
suritam9
2013.04.04 조회 2007
suritam9
2012.09.14 조회 2368
suritam9
2012.06.24 조회 2223
suritam9
2012.06.24 조회 2564
suritam9
2012.06.24 조회 2391
suritam9
2012.06.22 조회 2437
이전 1 2 3 4 5 6 7 8 9 10... 14다음
첨부 (0)
위로