I have a very strange problem with image downloads form Virtual Earth's tile server.
I have a Silverlight application that downloads image tiles to create a map. Everything works fine but I noticed some tiles would consistently not download and show a black image instead. The missing tiles are those that are all blue, as shown by VE on a large body of water - like a lake - in Road map style. If the tile has anything other than the blue pixels it all works fine. This was driving me crazy as I thought I was doing something very stupid so I wrote a test program on Blend 2 August Preview as shown below. The only thing I modified was 1) add the Image statements in the XAML, and 2) add the code to set the image sources in the Page_Loaded event.
When I run this code the images with source http://tiles.virtualearth.net/tiles/r021230030203033.png?g=1 display correctly but those with http://tiles.virtualearth.net/tiles/r021230030203031.png?g=1 do not, simply displaying a black square. This happens both for the images with Source defined in the XAML and those with the Source set in Page_Loaded.
To complete the strangeness, Blend's XAML editor properly shows both images when in the Design mode.
Any clues???
Enrique
First the Page.xaml file:
<Canvas
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:UntitledProject14="clr-namespace:UntitledProject14;assembly=ClientBin/UntitledProject14.dll"
Width="640" Height="480"
Background="Blue"
x:Class="UntitledProject14.Page;assembly=ClientBin/UntitledProject14.dll"
x:Name="Page"
>
<Image x:Name="image1" Canvas.Left="10" Canvas.Top="0" Width="256" Height="256" />
<Image x:Name="image2" Canvas.Left="300" Canvas.Top="0" Width="256" Height="256" />
<Image x:Name="image3" Canvas.Left="10" Canvas.Top="260" Width="256" Height="256" Source="http://tiles.virtualearth.net/tiles/r021230030203033.png?g=1" />
<Image x:Name="image4" Canvas.Left="300" Canvas.Top="260" Width="256" Height="256" Source="http://tiles.virtualearth.net/tiles/r021230030203031.png?g=1" />
</Canvas>
Now the Page.xaml.cs file:
using
System;
using
System.IO;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Media;namespace UntitledProject14
{
public partial class Page : Canvas
{
public Page()
{
this.Loaded += this.Page_Loaded;
}
private void Page_Loaded(object sender, EventArgs args)
{
// Required to initialize variables. Needs to be done from loaded event so FindName works properly.
InitializeComponent();
// Insert code required on object creation below this point.image1.Source = new Uri("http://tiles.virtualearth.net/tiles/r021230030203033.png?g=1", UriKind.RelativeOrAbsolute);image2.Source = new Uri("http://tiles.virtualearth.net/tiles/r021230030203031.png?g=1", UriKind.RelativeOrAbsolute);
}
}
}