How to pass the image value in one xaml page to another xaml page in windows phone 7?

前端 未结 1 593
闹比i
闹比i 2020-12-06 16:10

My Requirement is, in first xaml page place all the images .if whenever click on particular image that image can be displayed in another xaml page .How To pass The image val

相关标签:
1条回答
  • 2020-12-06 16:27

    There's a good screencast on different ways of navigating between pages (and passing values) from DimeCasts.net at http://www.dimecasts.net/Casts/CastDetails/174

    As an example of one way of doing this (and assuming the images were in a ListBox) would be to add the following to the SelectionChanged event.

    private void OnSelectedImageChanged(object sender, SelectionChangedEventArgs e)
    {
      NavigationService.Navigate(new Uri(string.Format("/image/{0}", HttpUtility.UrlEncode(((sender as ListBox).SelectedItem as PhotoViewModel).uri)), UriKind.Relative));
    }
    

    The above assumes an appropriately mapped route like:

    <nav:UriMapping Uri="/image/{image}" MappedUri="/Image.xaml?u={image}" />
    

    and that the original listbox was bound to the uri property of a PhotoViewModel object.

    Hopefully, watching the screencast should make any of the above clearer.

    0 讨论(0)
提交回复
热议问题