これが私の状況です...
Web サービスから JSON データを取得するパノラマが 1 つあります。画像、タイトル、コンテンツ、投稿日、ニュースの種類を含むニュースが含まれています。これで、以下の XAML コードを使用して、そのパノラマを生成して、それぞれの写真、タイトル、およびコンテンツを表示できます。
<controls:Panorama x:Name="NewsPanorama" ItemsSource="{Binding Items}" Title="" HorizontalAlignment="Left" Height="750" VerticalAlignment="Top" Width="477" Margin="-2,0,0,0">
<controls:Panorama.ItemTemplate>
<DataTemplate>
<controls:PanoramaItem Orientation="Horizontal" Header="{Binding Type}">
<Grid Height="595" VerticalAlignment="Top" Margin="0,-21,0,0">
<Image x:Name="imgAds1" HorizontalAlignment="Left" Height="595" VerticalAlignment="Top" Width="417" Source="{Binding Image.Url}" Stretch="UniformToFill"/>
<Rectangle Fill="Black" HorizontalAlignment="Left" Height="106" Margin="0,489,0,0" VerticalAlignment="Top" Width="417" Opacity="0.44"/>
<TextBlock x:Name="Title" HorizontalAlignment="Left" Height="81" Margin="7,489,0,0" TextWrapping="Wrap" Text="{Binding Title}" VerticalAlignment="Top" Width="397" FontSize="40"/>
<TextBlock x:Name="Content" HorizontalAlignment="Left" Height="40" Margin="7,540,0,0" TextWrapping="Wrap" Text="{Binding Content}" VerticalAlignment="Top" Width="397" FontSize="15"/>
<TextBlock x:Name="TypeOfContent" HorizontalAlignment="Left" Height="40" Margin="7,590,0,0" TextWrapping="Wrap" Text="{Binding Type}" VerticalAlignment="Top" Width="397" FontSize="15" Visibility="Collapsed"/>
</Grid>
</controls:PanoramaItem>
</DataTemplate>
</controls:Panorama.ItemTemplate>
<controls:Panorama.HeaderTemplate>
<DataTemplate>
<TextBlock Visibility="Collapsed" />
</DataTemplate>
</controls:Panorama.HeaderTemplate>
</controls:Panorama>
しかし、パノラマで Tab メソッドを使用してナビゲートしたい場合。ナビゲートされたページへのニュースのタイトルまたはタイプであるプロパティを取得する方法がわかりません。たとえば、ナビゲーション用に TypeOfContent TextBlock または {Binding Type} を取得したいのですが、その方法がわかりません。
これで、C# のナビゲーション コードは次のようになります。
void NewsPanorama_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
int selectedIndex = NewsPanorama.SelectedIndex;
//I just try something that doesn't work here.
/*Panorama panoramactrl = (Panorama)sender;
PanoramaItem panoramaItem = (PanoramaItem)(panoramactrl.SelectedItem);*/
//String header = NewsPanorama.SelectedItem.Header.ToString();
NavigationService.Navigate(new Uri("/ViewContentDetail.xaml?itemId=" + selectedIndex , UriKind.Relative));
}
selectedIndex を ViewContentDetail.xaml に送信できますが、NewsPanorama.SelectedItem のヘッダーをそのページに送信できないことがわかります。Web サービスから別の JSON を取得するには、PanoramaItem からいくつかのプロパティが必要だからです。
どうすればよいか、何か提案をいただけますか?
ありがとうございました。