Author Topic: WPF - Loading Images  (Read 1310 times)

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
WPF - Loading Images
« on: December 16, 2011, 02:11:57 pm »
Here is the WPF code to load the image.

Code: (C#)
//Source Code Listing


public LoadTestImage()
{
         BitmapImage myBitmapImageShip = new BitmapImage();
         myBitmapImageShip.BeginInit();
         myBitmapImageShip.UriSource = new Uri("c:\\ship.bmp");
         myBitmapImageShip.EndInit();
       
         Image myImageShip = new Image();
         myImageShip.Source = myBitmapImageShip;
         myImageShip.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(LoadImage_Failed);

         LayoutRoot.Children.Add(myImageShip);
}

void LoadImage_Failed(object sender, ExceptionRoutedEventArgs e)
{
            MessageBox.Show(e.ErrorException.ToString());
}


 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1