2013-01-15 48 views
0

我有兩個全景圖頁面。第一個包含字母,第二個包含以該字母開頭的動詞。當用戶點擊一個字母時,應用程序應該將它們重定向到帶有動詞的第二頁。我得到了Panorama的HeaderItem,但不是動詞列表。它只是空的。在XAML中綁定全景物品

這裏是第一頁上的事件:

// Navigate to the second page: 
     NavigationService.Navigate(new Uri("/Verbs.xaml?selectedItem=" + (alphabet.SelectedItem as ItemViewModel).ID, UriKind.Relative)); 

在第二頁:

protected override void OnNavigatedTo(NavigationEventArgs e) 
    { 
     if (DataContext == null) 
     { 
      string selectedIndex = ""; 
      if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex)) 
      { 
       int index = int.Parse(selectedIndex); 
       DataContext = App.ViewModel.Items[index];    
      } 
     } 
    } 

第二頁的XAML文件:

<Grid x:Name="LayoutRoot"> 
    <controls:Panorama Title="Verb"> 

     <!--Panorama item one--> 
     <!--Binding LineOne works!--> 
     <controls:PanoramaItem Header="{Binding LineOne}">     
      <ListBox x:Name="verblist" Margin="0,0,-12,0"> 
       <ListBox.ItemTemplate> 
        <DataTemplate> 
         <!--But this one does not work--> 
         <TextBlock Text="{Binding Verb1}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/> 
        </DataTemplate> 
       </ListBox.ItemTemplate> 
      </ListBox> 
     </controls:PanoramaItem> 

     <!--Panorama item two--> 
     <controls:PanoramaItem Header="Search"> 
      <Grid/> 
     </controls:PanoramaItem> 
    </controls:Panorama> 
</Grid> 

你能告訴我p roblems?

謝謝!

回答

1

你忘了將項目添加到列表框中,

<ListBox x:Name="verblist" Margin="0,0,-12,0" Items={Binding YOUR_ITEMS_LOCATION_HERE}> 

或代碼:

verblist.Items = xxxx;