【问题标题】:Windows Phone 7.1 live tile background images not settingWindows Phone 7.1 动态磁贴背景图像未设置
【发布时间】:2014-04-08 10:37:36
【问题描述】:

我正在尝试更改 Windows Phone 7.1 应用程序的动态磁贴的背景图像(正面和背面),但从未设置过背景图像。我已将图像添加到项目中,并确保在 Uri() 构造函数中正确指定它们的名称。我似乎无法检测到问题。这是代码。

public partial class MainPage : PhoneApplicationPage
{
    // Constructor
    public MainPage()
    {
        InitializeComponent();
    }

    String result = "Default";
    String company = "";
    String image = "";

    //Method That Executes After Every DownloadStringAsync() Call by WebClient 
    public void wb_DownloadStringCompleted(Object sender, DownloadStringCompletedEventArgs e)
    {
        result = e.Result;

        int newCount = 1;

        // Application Tile is always the first Tile, even if it is not pinned to Start.
        ShellTile TileToFind = ShellTile.ActiveTiles.First();

        // Application should always be found
        if (TileToFind != null)
        {
            // Set the properties to update for the Application Tile.
            // Empty strings for the text values and URIs will result in the property being cleared.
            StandardTileData NewTileData = new StandardTileData
            {
                Title = "Stocks App",
                BackgroundImage = new Uri(image, UriKind.Relative),
                Count = newCount,
                BackTitle = company,
                BackBackgroundImage = new Uri(image, UriKind.Relative), //**The problem is here**
                BackContent = result
            };

            // Update the Application Tile
            TileToFind.Update(NewTileData);
        }
    }

    //Method for Radio Button When Google is Selected
    private void radioButton1_Checked(object sender, RoutedEventArgs e)
    {
        company = "Google Stock";
        image = "google_icon.png";
        WebClient wb = new WebClient();
        wb.DownloadStringAsync(new Uri("http://finance.yahoo.com/d/quotes.csv?s=GOOG&f=a"));
        wb.DownloadStringCompleted += wb_DownloadStringCompleted;
    }

    //Method for Radio Button When Yahoo is Selected
    private void yahooRadioBtn_Checked(object sender, RoutedEventArgs e)
    {
        company = "Yahoo Stock";
        image = "yahoo_icon.png";
        WebClient wb = new WebClient();
        wb.DownloadStringAsync(new Uri("http://finance.yahoo.com/d/quotes.csv?s=YHOO&f=a"));
        wb.DownloadStringCompleted += wb_DownloadStringCompleted;
    }

    //Method for Radio Button When Apple is Selected
    private void appleRadioBtn_Checked(object sender, RoutedEventArgs e)
    {
        company = "Apple Stock";
        image = "apple_icon.png";
        WebClient wb = new WebClient();
        wb.DownloadStringAsync(new Uri("http://finance.yahoo.com/d/quotes.csv?s=AAPL&f=a"));
        wb.DownloadStringCompleted += wb_DownloadStringCompleted;
    }   
}

【问题讨论】:

标签: c# windows windows-phone-7 live-tile


【解决方案1】:

验证图像的路径和构建操作是否符合文档的要求

您可以通过
http://msdn.microsoft.com/en-US/library/windowsphone/develop/microsoft.phone.shell.standardtiledata.backbackgroundimage(v=vs.105).aspx

了解更多信息

和

http://msdn.microsoft.com/en-US/library/windowsphone/develop/ff402541(v=vs.105).aspx

在任何其他检查之前检查您的文件 Build Action 属性设置为 Content

【讨论】:

  • 请编辑它,以便其他遇到它的人更容易。对于这个特定的问题,将 Bulid Action 设置为“内容”是解决方案。之后您仍然可以提供链接
  • 您应该在问题中发布一个屏幕截图,其中包含构建操作不起作用时。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-19
相关资源
最近更新 更多