'파라미터'에 해당되는 글 1건

  1. 2011.03.24 [WP7] 페이지 이동간의 파라미터 주기
Windows Phone 72011. 3. 24. 16:05

이건 정말 옛날부터 알았던건데 혹시나 까먹을까 해서 쓴다.

 

NavigationServce.Navigate를 이용해서 페이지를 이동할때

 

var uri = new Uri(string.Format("/HugeFlow.Phone.Controls;component/AboutControl/AboutPage.xaml?AppName={0}&Version={1}&SiteAddress={2}&EmailAddress={3}&Year={4}&Company={5}"
                , appName, version, siteAddress, emailAddress, year, companyName), UriKind.RelativeOrAbsolute);

 

이런식으로 파라미터를 줄수 있다 웹과 같다.

 

그렇다면 받는쪽에서는 어떡해 할까?

 

받는 페이지에는

 

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
       {
           base.OnNavigatedTo(e);
 
           string appName;
           string version;            
           string siteAddress;
           string emailAddress;
           string year;
           string companyName;
 
           if (NavigationContext.QueryString.TryGetValue("AppName", out appName) == true)
           {
               AboutPageControl.AppName = appName;
           }
 
           if (NavigationContext.QueryString.TryGetValue("Version", out version) == true)
           {
               AboutPageControl.Version = version;
           }
 
           if (NavigationContext.QueryString.TryGetValue("SiteAddress", out siteAddress) == true)
           {
               AboutPageControl.SiteAddress = siteAddress;
           }
 
           if (NavigationContext.QueryString.TryGetValue("EmailAddress", out emailAddress) == true)
           {
               AboutPageControl.EmailAddress = emailAddress;
           }
 
           if (NavigationContext.QueryString.TryGetValue("Year", out year) == true)
           {
               AboutPageControl.Year = year;
           }
 
           if (NavigationContext.QueryString.TryGetValue("CompanyName", out companyName) == true)
           {
               AboutPageControl.CompanyName = companyName;
           }
       }

 

이렇게 하면 된다.

Posted by 동동(이재동)