I feel silly asking this, but so far I haven't been able to solve this problem by myself, so here goes.
I'm trying to dynamically add a StackPanel to a Canvas, which works, but I also need to add an Image to the same StackPanel, which does not yet work. My code for this looks like this:
public void CreateInfo()
StackPanel info = new StackPanel();
TextBlock authorBlock = new TextBlock();
TextBlock extraBlock = new TextBlock();
info.Height = 500;
info.Width = 500;
authorBlock.Text = "Some text to test.";
System.Windows.Controls.Image img = new System.Windows.Controls.Image(); // I needed to disambiguate Image.
img.Source = new BitmapImage(new Uri("/Trex;component/Resources/icons/fire.png", UriKind.RelativeOrAbsolute)); // fire.png is something like 24 x 44 pixels.
View Complete Post