2014-04-08 83 views
0

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

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; 
    } 
} 
+0

只有当瓦片翻转时才会看到'BackBackgroundImage' – csharpwinphonexaml

+0

@verdesrobert是的。但是,在发生翻转时,“BackBackgroundImage”仍然是默认的红色颜色 – Fourth

+0

阅读此内容并验证图像和生成操作的路径是否符合文档要求 – csharpwinphonexaml

回答

0

验证是由文档请求的图像的路径和生成操作

您可以更在
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

+0

请编辑此代码,以便其他任何碰到它的人更容易。对于这个特殊问题,将Bulid Action设置为“content”是解决方案。您仍然可以在此之后提供链接 – Fourth

+0

您应该在问题中发布构建操作的屏幕截图,当它不起作用时。 – csharpwinphonexaml