簡體   English   中英

根據xaml windows phone傳遞的參數顯示項目數

[英]Displaying number of items according to parameters passed xaml windows phone

好吧,我有一個MainPage.xaml

這將參數傳遞給NextPage.xaml,如下所示NextPage.xaml?count = 10

現在我想在長列表選擇器上顯示10個項目,這個數字取決於傳遞的參數我該怎么做,我可以動態綁定數據嗎?

NavigationService.Navigate(new Uri("/Pagina2.xaml?count=10", UriKind.Relative));

你做什么。 如果你想傳遞一個包含整數10的varibale:

int getInteger= 10;
NavigationService.Navigate(new Uri("/Pagina2.xaml?count="+getInteger, UriKind.Relative));

您可以像這樣獲取導航參數:

if (NavigationContext.QueryString.ContainsKey("count"))
        {
            var countString = NavigationContext.QueryString["count"];
            var count = Int32.Parse(countString);
            // Create list
            for(int i = 0; i < count; i++) 
            {
                 MyLLSList.Add(new Item());
            }
        }

其中MyLLSList是ViewModel中的屬性,您可以將其綁定為LLS ItemSource。

希望這個對你有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM