-1

リストボックスの項目をタップすると新しいページが開くパノラマアプリケーションを実行しようとしています。リストボックスは画像とテキストボックスで構成されているので、画像の名前を新しいページに取り込みたいとタップします。何かアドバイス??(下手な英語でごめんなさい)

4

2 に答える 2

1

試す:

               <ListBox ItemsSource="{Binding Items}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <Image Source="{Binding ImageUrl}" Tag="{Binding ImageName}" Tap="Image_Tap"/>
                                <TextBlock Text="{Binding Text}"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

背後のコードで

private void Image_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
   Image img = sender as Image;
   String name = img.Tag.ToString();
   NavigationService.Navigate(new Uri("Page2.xaml?ImageName="+name,UriKind.Relative));
}

Page2.xaml.cs

    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        String Name = NavigationContext.QueryString["ImageName"];
        base.OnNavigatedTo(e);
    }
于 2012-09-28T14:06:06.423 に答える
0

この例に示すように、パラメーターを渡すことができます。

そのため、Tap イベントでは、画像名を取得し、それを任意の文字列に保存して、クエリ パラメータとして渡す必要があります。

var url = "/Views/PageName.xaml?imageName=" + imageName;
NavigationService.Navigate(new Uri(url ,UriKind.Relative));
于 2012-09-28T14:03:27.617 に答える