0

ユーザーが移動した場所からページをピン留めできるようにしたいのですが、ユーザーがピン留めするために選択したアイテムに応じて、そのコンテンツを動的に表示したいと考えています。最初のセカンダリ タイル、できましたが、問題は、スタート メニューに複数のセカンダリ タイルがある場合、すべてのセカンダリ タイルはページへのリンクですが、ページのコンテンツはすべて前回と同じです。二次タイル。

これが私がすることです:

ページの移動先から情報を受け取り、次のようにページに表示するように設定します。

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


            if (!IsolatedStorageSettings.ApplicationSettings.Contains("isolated_image"))
            {
                IsolatedStorageSettings.ApplicationSettings.Add("isolated_image", NavigationContext.QueryString["pro_image"] as string);
            }
![enter image description here][1]
            imageBase = (IsolatedStorageSettings.ApplicationSettings["isolated_image"] as string);

            StreamResourceInfo sri = null;


            Uri uri = new Uri(imageBase, UriKind.Relative);
            uriString = uri.ToString();
            sri = Application.GetResourceStream(uri);
            BitmapImage bitmap = new BitmapImage();
            bitmap.SetSource(sri.Stream);

            base64 = ((App)Application.Current).ImageToBase64(bitmap);

            item_image.Source = ((App)Application.Current).ImageFromBase64(base64);

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

            }

            ShellTile secondaryTile = this.FindTile(SecondaryTileUriSource);

            if (secondaryTile != null)
            {

                item_image.Source = ((App)Application.Current).ImageFromBase64(base64);
            }

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

        }

私が得た情報から、ユーザーがピン アプリ バーを押すと、 "?image_item="+imageBase"に基づいて一意の uri を持つセカンダリ タイルを作成します

  void btnPin_Click(object sender, EventArgs e)
        {       
            ShellTile tile = this.FindTile(SecondaryTileUriSource);
            if(tile==null)
            {

                StandardTileData tileData = this.GetSecondaryTileData();

                 Uri uri = new Uri("/All Files/Product Files/Dry/Product Detail.xaml?item_image=" + imageBase, UriKind.Relative);

                 MessageBox.Show("the link uri is "+ uri.ToString());

                ShellTile.Create(uri, tileData);


            }
        }

最後に、スタート メニューに複数のセカンダリ タイルがある場合、最初と 2 番目のセカンダリ タイルは、最後にピン留めしたこのセカンダリ タイルのようにページに同じコンテンツを表示します。

リンク uri は既に一意であると確信しています。そうしないと、複数のセカンダリ タイルを作成できませんでした。誰が私を助けることができますか?ありがとう

4

1 に答える 1

0

まず、固定ロジックを変更し、画像データから文字列を作成する代わりに、ある種の ID を使用して画像を識別します...現在のアプローチは不必要に複雑です。

イメージ 1、イメージ 2、イメージ 3 などのように簡単に作成できます。次に、クエリ文字列から id を取得し、次のような画像 uri を作成します。new Uri("../image" + id)

複数のセカンダリ タイルを正常に作成した場合、それぞれが一意である必要があり、問題はおそらくクエリ文字列の解析にあります。OnNavigatedTo()

于 2014-09-21T10:10:56.750 に答える