在XAML中绑定全景项目

在XAML中绑定全景项目,xaml,windows-phone,Xaml,Windows Phone,我有两页全景图。第一个包含字母,第二个包含以该字母开头的动词。当用户点击字母时,应用程序应将其重定向到带有动词的第二页。我得到了全景图的标题,但没有动词列表。它只是空的 以下是第一页上的事件: // Navigate to the second page: NavigationService.Navigate(new Uri("/Verbs.xaml?selectedItem=" + (alphabet.SelectedItem as ItemViewModel).ID, Uri

我有两页全景图。第一个包含字母,第二个包含以该字母开头的动词。当用户点击字母时,应用程序应将其重定向到带有动词的第二页。我得到了全景图的标题,但没有动词列表。它只是空的

以下是第一页上的事件:

// 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];            
            }
        }
    }
<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>
第二页的XAML文件:

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];            
            }
        }
    }
<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>

你能给我看看问题吗


谢谢

您忘记将项目添加到列表框

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