【问题标题】:How to Place a xaml Control in windows phone to display in a secondary tile?如何在 windows phone 中放置 xaml 控件以显示在辅助磁贴中?
【发布时间】:2012-10-12 10:59:37
【问题描述】:

我想为我的 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);
        }

【问题讨论】:

    标签: c# windows-phone-7.1


    【解决方案1】:

    从您的控件生成图像

    /// /// 执行渲染和存储图像 /// /// 渲染 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

    【讨论】:

    • Cna 我们在里面放置了一个马赛克瓷砖作为辅助瓷砖,它看起来像 windows phone 中的人瓷砖。 .
    • 不,您受限于对图像的引用。但是您可以尝试从后台工作人员生成/更新此图像,使其看起来像马赛克。在 Windows Phone 8 中会有更多的选择。
    • 好的,谢谢您的回复!我了解情景先生。 . .请为我的问题投票,如果您考虑,这很有用。 . .
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多