using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;
namespace SilverlightApplication12
{
public partial class Page : UserControl
{
private Image grass;
public Page()
{
InitializeComponent();
LoadImage("grass.png");
}
private void LoadImage(string path)
{
Uri uri = new Uri(path, UriKind.Relative);
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.UriSource = uri;
bitmapImage.DownloadProgress +=
new EventHandler<DownloadProgressEventArgs>(bitmapImage_DownloadProgress);
grass = new Image();
grass.Source = bitmapImage;
GameCanvas.Children.Add(grass);
}
void bitmapImage_DownloadProgress(object sender, DownloadProgressEventArgs e)
{
if (e.Progress == 100)
{
Dispatcher.BeginInvoke(delegate()
{
double height = grass.ActualHeight;
double width = grass.ActualWidth;
});
}
}
}
}