簡體   English   中英

從“全景頁面”導航到非全景頁面(列表項)

[英]Navigate from Panorama Page to a non-Panorama Page (listitems)

這是我的Panorama頁面項的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>

這是我在Panorama頁面中的代碼。

私人空白lbDeelnemer_SelectionChanged(對象發送者,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
    }

這是我來自非全景頁面的代碼。

受保護的覆蓋無效void OnNavigatedTo(NavigationEventArgs e){//第二次嘗試字符串strItemIndex; 如果(NavigationContext.QueryString.TryGetValue(“ goto”,outstrItemIndex))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];
        }
    }

我的問題是,我想像使用默認數據綁定應用程序一樣進行導航。 您單擊第一個列表項,然后轉到新頁面(非全景)。 看起來很簡單,但我找不到。

嘗試將標簽屬性綁定到索引/項目值

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

暫無
暫無

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

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