我希望能够固定用户导航到的页面,我希望根据用户选择固定的项目动态显示其内容。第一个辅助磁贴,我可以做,但问题是当开始菜单有多个辅助磁贴时,所有辅助磁贴都链接到页面但页面内容都与最后一个相同次要瓷砖。
这是我所做的:
从页面导航到的位置,我收到信息并将其设置在页面上,如下所示:
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;
}
根据我得到的信息,当用户按下 pin 应用栏时,我创建了具有基于“?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);
}
}
最后,当我在开始菜单中有多个辅助磁贴时,第一个和第二个辅助磁贴将在页面上显示相同的内容,就像我固定的最后一个辅助磁贴一样。
我确定链接 uri 已经是唯一的;否则,我无法创建多个辅助图块。谁能帮我出什么问题?谢谢