从全景页导航到非全景页(列表)

本文关键字:全景 列表 导航 | 更新日期: 2023-09-27 18:08:12

这是我的全景页面项目的示例。

<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(对象发送者,SelectionChangedEventArgs e){#region to specific deelnemerinfo screen

        // 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){//第二次尝试字符串strItemIndex;如果(NavigationContext.QueryString。TryGetValue("goto", out strItemIndex))PanoramaControl。DefaultItem = myppanorama . 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];
        }
    }

我的问题,我想导航像你做一个默认的绑定应用程序。你点击第一个列表项,你进入一个新的页面(非全景)。看起来很简单,但是我找不到。

从全景页导航到非全景页(列表)

尝试将tag属性绑定到index/itemvalue

       <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))