I have a stack panel in my XAML page.
<StackPanel Name="xamlimg" Orientation="Vertical" Grid.column="1">
</StackPanel>
I want to add an image in this stackpanel
using C# code behind the XAML page.
I have attempted using the structure below, but I can't seem to set the source right.
Image img = new Image();
img.Source= //Image Source here
xamlimg.Children.Add(img);
How do I set the image source and add it to the stackpanel
?
You can assign image source using below code:
image.Source = new BitmapImage(new Uri("/MyNameSpace;images/someimage.png", UriKind.Relative));
Thanks