I want to know how I add an image in a wpf application in the c# code ?
I want to add this image :
<Image Name="imgRubanbleu" Source="Objet/rubanbleu.png" Height="19"
Margin="34,252,354,231" RenderTransformOrigin="0.5,0.5" />
On this image :
<Image Source="Images/terrain.png" Grid.Row="4" Grid.RowSpan="4" Grid.Column="0" MouseUp="Image_MouseUp_1"/>
When I click on it...
I tried to do this :
private void Image_MouseUp_1(object sender, MouseButtonEventArgs e)
{
Image myImage = new Image();
myImage.Width = 200;
// Create source
BitmapImage myBitmapImage = new BitmapImage();
// BitmapImage.UriSource must be in a BeginInit/EndInit block
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@"Objet/rubanbleu.png");
myBitmapImage.EndInit();
//set image source
myImage.Source = myBitmapImage;
}
(http://msdn.microsoft.com/en-us/library/system.windows.controls.image.aspx)
But It still doesn't work...
(Sorry for my english level, I usually work in french)