Question

I am trying to change the background images (front and back) of the live tile for a windows phone 7.1 app however the background images are never set. I've added the images to the project and have made sure to specify their names properly in the Uri() constructor. I can't seem to be able to detect the problem. Here's the code.

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;
    }   
}
Was it helpful?

Solution

Verify that the path of the image and the Build Action is as requested by the documentation

You can find out more at
http://msdn.microsoft.com/en-US/library/windowsphone/develop/microsoft.phone.shell.standardtiledata.backbackgroundimage(v=vs.105).aspx

and

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

Check your files Build Action property is set to Content before any other check

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top