1

我想为我的 windows phone 应用程序创建一个辅助磁贴,它在我的主页中显示控件,例如,如何显示一个面板控件(其中包含内部图像)以显示在辅助磁贴中。

    public void CreateSecondaryTile()
    {
        ShellTile secTile = ShellTile.ActiveTiles.SingleOrDefault(x => x.NavigationUri.ToString().Contains("MainPage.xaml"));
        if (secTile == null)
        {
            StandardTileData fullTile = new StandardTileData()
            {
                //'*** Primary Tile Properties ***
                BackgroundImage = new Uri(controlName, UriKind.Relative),
                Count = DateTime.Now.Second,
                Title = "Front Title",

                //'*** Secondary Tile Properties ***
                BackBackgroundImage = new Uri("Background.png", UriKind.Relative),
                BackContent = "Back Content",
                BackTitle = "Back Title"
            };
            ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), fullTile);
        }
4

1 回答 1

2

从您的控件生成图像

/// /// 执行渲染和存储图像 /// /// 渲染 UIElement /// 存储图像的 Uri private static void RenderAndStoreImage(UIElement element, string uri) { try { var writeableBitmap = new WriteableBitmap(173, 173) ; writeableBitmap.Render(element, new TranslateTransform());

  using (var store = IsolatedStorageFile.GetUserStoreForApplication())
  {           using (var stream = store.OpenFile(uri, FileMode.OpenOrCreate))
      {
          writeableBitmap.Invalidate();
          writeableBitmap.SaveJpeg(stream, 173, 173, 0, 100);             }       }   }   catch (Exception ex)    {       Logger.Log(ex);     }

}

创建辅助磁贴

http://www.windowsphonegeek.com/articles/How-to-add-and-remove-Secondary-Tiles-in-Windows-Phone-apps

于 2012-10-13T20:47:24.417 回答