C# 如何在windows phone 8中的辅助磁贴中传递图像

C# 如何在windows phone 8中的辅助磁贴中传递图像,c#,windows-phone-7,windows-phone-8,visual-studio-2013,C#,Windows Phone 7,Windows Phone 8,Visual Studio 2013,我正在寻找一种方法,将图像作为字符串传递,并在下一页将其转换为图像类型BitmapImage,因为我知道我们无法将图像本身传递到下一页,或者尝试按任何电话状态序列化imageSource,这将给出一个错误。我一直在尝试将其作为uri参数的一部分传递,并使用NavigationContext.QueryString获取它,但从中获取的数据始终是{System.Windows.Media.Imaging.BitmapImage};因此,页面上不显示图像。了解到我可以使用PhoneApplicatio

我正在寻找一种方法,将图像作为字符串传递,并在下一页将其转换为图像类型BitmapImage,因为我知道我们无法将图像本身传递到下一页,或者尝试按任何电话状态序列化imageSource,这将给出一个错误。我一直在尝试将其作为uri参数的一部分传递,并使用NavigationContext.QueryString获取它,但从中获取的数据始终是{System.Windows.Media.Imaging.BitmapImage};因此,页面上不显示图像。了解到我可以使用PhoneApplicationService.Current.State作为BitmapImage来显示图像,但在我的应用程序中,我希望使用直接链接到固定页面并通过其所有以前页面的辅助磁贴;因此,当从辅助磁贴启动应用程序时,PhoneApplication.Current.State未按预期填充。所以,我不会在任何电话状态下完全回复二级互动程序

有没有其他方法可以克服这个问题,你能举个例子来说明吗

我的当前代码:Product Detail.xaml.cs

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            /***
             * 
             *  Trying to get image from uri parameter and covert it to BitmapImage using getImage(string) method in App.xaml.cs
             *  
             *   public ImageSource getImage(string p)
                {
                    return new BitmapImage(new Uri(p, UriKind.Relative));

                }
             * 
             * */

            item_image.Source = ((App)Application.Current).getImage(NavigationContext.QueryString["pro_image"]);


            if (!(IsolatedStorageSettings.ApplicationSettings.Contains("item_name")))
            {
                IsolatedStorageSettings.ApplicationSettings.Add("item_name", PhoneApplicationService.Current.State["pro_name"]);

            }

            ShellTile secondaryTile = this.FindTile(SecondaryTileUriSource);

            if (secondaryTile != null)
            {

                // *****************************************************      tile.Delete();


                txtb_product_name.Text = PhoneApplicationService.Current.State["pro_name"] as string;

                txtb_product_name.Text = PhoneApplicationService.Current.State["pro_name"] as string;



            }
        }
这里是produt list.xaml.cs,其中列出了供用户选择的产品列表,有关此选定产品的所有相关信息将显示在product Detail.xaml页面

Product list.xaml.cs

  private void lst_product_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lst_product.SelectedItem != null)
            {
                PhoneApplicationService.Current.State["pro_name"] = (lst_product.SelectedItem as ProductsDry).ItemDryName;
                PhoneApplicationService.Current.State["pro_id"] = (lst_product.SelectedItem as ProductsDry).ItemDryId;
              PhoneApplicationService.Current.State["pro_image"] = (lst_product.SelectedItem as ProductsDry).ItemDryImage;
                PhoneApplicationService.Current.State["ItemDryIngridient"] = (lst_product.SelectedItem as ProductsDry).ItemDryIngredients;
                PhoneApplicationService.Current.State["ItemDryUse"] = (lst_product.SelectedItem as ProductsDry).ItemDryUse;
                PhoneApplicationService.Current.State["ItemDryDesc1"] = (lst_product.SelectedItem as ProductsDry).ItemDryDesc1;
                PhoneApplicationService.Current.State["ItemDryDesc2"] = (lst_product.SelectedItem as ProductsDry).ItemDryDesc2;
                PhoneApplicationService.Current.State["ItemDryUse"] = (lst_product.SelectedItem as ProductsDry).ItemDryUse;

                IsolatedStorageSettings.ApplicationSettings.Clear(); 
                NavigationService.Navigate(new Uri("/All Files/Product Files/Dry/Product Detail.xaml?&pro_name=" + (lst_product.SelectedItem as ProductsDry).ItemDryName + "&pro_image=" + (lst_product.SelectedItem as ProductsDry).ItemDryImage, UriKind.Relative));
            }
            else return;
        }

        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);
            IsolatedStorageSettings.ApplicationSettings.Clear();
        }
在产品详细信息页面上,用户可以锁定他最喜欢的产品的页面,在这里,我对从产品列表发送到产品详细信息的图像有问题


如果您需要更多信息,请告诉我,谢谢。

显示您现在正在执行的操作的代码示例。您可以尝试将图像本身序列化为base64,并通过查询参数传递它,您还可以传递图像的位置(如果它存在于某处)。@Erti-ChrisEelmaa-I编辑了我的问题以添加代码,thanks@Erti-克丽塞尔玛:有什么评论吗?很难看出发生了什么。我看到OnNavigatedTo方法尝试访问QueryStringpro_图像。填充此pro_图像的代码在哪里?没有人在任何地方填这个。试着看看是否可以添加相关代码并删除任何不必要的内容。@Erti ChrisEelmaa我编辑了我的问题以了解更多细节。希望能让你更清楚我的问题,如果不是,请告诉我,谢谢