Reputation: 225
I can't find the reason why the image won't display in the grid I created
Image img = new Image();
img.Source = new BitmapImage(new Uri(@"C:\logo.bmp", UriKind.Relative));
img.Width = 50;
img.Height = 50;
img.Margin = new Thickness(5, 5, 5, 5);
grid1.Children.Add(img);
Upvotes: 0
Views: 91
Reputation: 128013
Your image URI is an absolute path.
You should write
img.Source = new BitmapImage(new Uri(@"C:\logo.bmp", UriKind.Absolute));
or better
img.Source = new BitmapImage(new Uri(@"C:\logo.bmp"));
Upvotes: 3