【问题标题】:Trying to set a tile's background to images from the internet尝试将磁贴的背景设置为来自互联网的图像
【发布时间】:2013-01-13 05:51:58
【问题描述】:

当我执行此代码时,磁贴将是空的,谁能向我解释为什么以及如何解决它?

private void CreateCycleTileWide()
    {
        if (!Mangopollo.Utils.CanUseLiveTiles)
        {
            MessageBox.Show("This feature needs Windows Phone 7.8");
            return;
        }

        try
        {

此代码从 reddit 获取一个 json 提要,submission.data.thumbnail 看起来像“http://someaddress.com/something.png”。

            Submission orig;
            for (int cur = 0; cur < App.ViewModel.PicsSubmissionList.Count; cur++)
            {
                orig = App.ViewModel.PicsSubmissionList[cur];
                Submission submission = orig;

                Dispatcher.BeginInvoke(() =>
                {

                    if (!string.IsNullOrEmpty(submission.data.thumbnail))
                    {
                        try
                        {
                            list.Add(new Uri(submission.data.thumbnail));
                        }
                        catch { MessageBox.Show("Can't generate list"); }
                    }
                });
            }

此代码根据之前的 URI 列表创建磁贴。

            try
            {
                var mytile = new CycleTileData
                {
                    Title = "Reddit /r/Pics",
                    Count = 0,
                    SmallBackgroundImage = new Uri("/images/RedditLogo.png", UriKind.Relative),
                    CycleImages = list
                };
                ShellTileExt.Create(new Uri("/MainPage.xaml?msg=fromwidetile", UriKind.Relative), mytile, true);
            }
            catch { MessageBox.Show("cantcreatetile"); }
        }
        catch
        {
            MessageBox.Show("remove tile before creating it again");
        }
    }

提前致谢,马克斯。

【问题讨论】:

    标签: c# windows-phone-7 uri tile reddit


    【解决方案1】:

    所有类型的图块仅支持本地图像。不支持远程图像(不在设备上)。你应该先save your remote images to isolated storage

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多