ユーザーが移動した場所からページをピン留めできるようにしたいのですが、ユーザーがピン留めするために選択したアイテムに応じて、そのコンテンツを動的に表示したいと考えています。最初のセカンダリ タイル、できましたが、問題は、スタート メニューに複数のセカンダリ タイルがある場合、すべてのセカンダリ タイルはページへのリンクですが、ページのコンテンツはすべて前回と同じです。二次タイル。
これが私がすることです:
ページの移動先から情報を受け取り、次のようにページに表示するように設定します。
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 は既に一意であると確信しています。そうしないと、複数のセカンダリ タイルを作成できませんでした。誰が私を助けることができますか?ありがとう