簡體   English   中英

Windows Phone 7.1實時平鋪背景圖像未設置

[英]Windows Phone 7.1 live tile background images not setting

我正在嘗試為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;
    }   
}

驗證映像和構建操作的路徑是否符合文檔的要求

您可以在以下找到更多
http://msdn.microsoft.com/zh-CN/library/windowsphone/develop/microsoft.phone.shell.standardtiledata.backbackgroundimage(v=vs.105).aspx

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

在進行任何其他檢查之前,將文件“ Build Action屬性設置為“ Content

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM