2015-01-01 92 views
1

正在關注this msdn教程展示瞭如何將參數從一個頁面傳遞到另一個頁面。如何在Windows Store頁面之間傳遞多個參數?

private void HyperlinkButton_Click(object sender, RoutedEventArgs e) 
{ 
    this.Frame.Navigate(typeof(BasicPage2), tb1.Text); 
} 

private void navigationHelper_LoadState(object sender, LoadStateEventArgs e) 
{ 
    string name = e.NavigationParameter as string; 

    if (!string.IsNullOrWhiteSpace(name)) 
    { 
     tb1.Text = "Hello, " + name; 
    } 
    else 
    { 
     tb1.Text = "Name is required. Go back and enter a name."; 
    } 
} 

但是,如何傳遞多個參數?

我需要傳遞2個集合(2個列表是特定的)。怎麼做?

回答

0

如果你想傳遞兩個集合創建一個類並在類中初始化你的集合並將它作爲參數傳遞。

class collectionscontainer 
{ 
    private list<urlist> list1; 
    private list<urlist> list1; 
} 
Class Classname 
{ 
    public void Methord(collectionscontainer c) 
    { 
    //hear u will get access of both lists 
    } 
} 
+0

我想這就是需要做的。我只是擔心,因爲從[在C#中的頁面之間傳遞複雜對象]接受的答案(http://stackoverflow.com/questions/20035668/pass-complex-object-between-pages-in-c-sharp)有評論「Passing複雜對象作爲導航參數將導致您的應用程序崩潰從暫停恢復(按此處[stackoverflow.com/questions/20049589/...](http://stackoverflow.com/questions/20049589/windows-store-apps- my-app-terminate-after-being-switched));「 – gefu654