0

这是我的全景页面项目的 xaml。

<controls:PanoramaItem x:Name="deeln" Header="Deelnemers" Style="{StaticResource subtitle}">
                <!--Double line list with image placeholder and text wrapping-->
                <ListBox Margin="12,0,-12,0" ItemsSource="{Binding ItemsDeelnemer}" x:Name="lbDeelnemer" SelectionChanged="lbDeelnemer_SelectionChanged">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled">
                                <StackPanel Orientation="Horizontal" Margin="0,0,0,17">
                                    <TextBlock Foreground="Black" TextWrapping="Wrap" Text="{Binding LineNr}" Style="{StaticResource PhoneTextExtraLargeStyle}" ></TextBlock>
                                    <StackPanel Width="430" Height="100">
                                        <TextBlock Foreground="Black" TextWrapping="Wrap" Text="{Binding LineNaamWielrenner1}" Style="{StaticResource PhoneTextExtraLargeStyle}" FontSize="35"></TextBlock>
                                        <TextBlock Foreground="Black" TextWrapping="Wrap" Text="{Binding LineNaamWielrenner2}" Style="{StaticResource PhoneTextExtraLargeStyle}" FontSize="35"></TextBlock>
                                    </StackPanel>
                                </StackPanel>
                            </ScrollViewer>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PanoramaItem>

这是我在全景页面中的代码。

private void lbDeelnemer_SelectionChanged(object sender, SelectionChangedEventArgs e) { #region 转到特定的 deelnemerinfo 屏幕

        // If selected index is -1 (no selection) do nothing
        if (lbDeelnemer.SelectedIndex == -1)
            return;

        // Navigate to the new page

        if (lbDeelnemer.SelectedIndex == 0)
        {
            NavigationService.Navigate(new Uri("/DeelnemerInfo.xaml", UriKind.Relative));
            //NavigationService.Navigate(new Uri("/DeelnemerInfo.xaml?selectedItem=" + lbDeelnemer.SelectedIndex, UriKind.Relative));
        }

        // Reset selected index to -1 (no selection)
        lbDeelnemer.SelectedIndex = -1;

        #endregion
    }

这是我来自非全景页面的代码。

protected override void OnNavigatedTo(NavigationEventArgs e) { //第二次尝试 string strItemIndex; if (NavigationContext.QueryString.TryGetValue("goto", out strItemIndex)) PanoramaControl.DefaultItem = MyPanorama.Items[Convert.ToInt32(strItemIndex)];

        base.OnNavigatedTo(e);

        //first try
        string selectedIndex = "";
        if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
        {
            int index = int.Parse(selectedIndex);
            DataContext = App.ViewModel.ItemsDeelnemer[index];
        }
    }

我的问题,我想像使用默认数据绑定应用程序一样导航。您单击第一个列表项,然后转到新页面(非全景)。它看起来很简单,但我找不到它。

4

1 回答 1

0

尝试将标签属性绑定到索引/项目值

       <ListBox>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <HyperlinkButton Tag="{Binding FileName}" Click="location_Click"/>
                        <TextBlock Text="{Binding DateCreated}"/>                                       
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

相应地导航

private void location_Click(object sender, RoutedEventArgs e)
        {
            HyperlinkButton clicked = (HyperlinkButton)sender;
            string uri = "/noteapp;component/ViewEdit.xaml?id=" + clicked.Tag;
            NavigationService.Navigate(new Uri(uri, UriKind.Relative));
        }

并在 panaroma 页面上使用类似这样的东西来检索值

filename = NavigationContext.QueryString["id"];
var storage = IsolatedStorageFile.GetUserStoreForApplication();
using (var file = storage.OpenFile(filename, FileMode.Open))
于 2013-04-09T18:20:14.697 回答