我正在尝试更改Windows Phone 7.1 app的实时图块的背景图像(正面和背面),但是从不设置背景图像。我已将图像添加到项目中,并确保在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;
}
}
答案 0 :(得分:0)
验证图像的路径和构建操作是否符合文档
的要求和
http://msdn.microsoft.com/en-US/library/windowsphone/develop/ff402541(v=vs.105).aspx
在进行任何其他检查之前,检查您的文件Build Action
属性设置为Content