You need to set binding. This code will make your picture to fit height and width of your source element.
var _img = new Image { Stretch = Stretch.Fill, StretchDirection = StretchDirection.Both };
var height = new Binding("ActualHeight") {Source = yourSource };
var width = new Binding("ActualWidth") { Source = yourSource};
_img.SetBinding(FrameworkElement.WidthProperty, width);
_img.SetBinding(FrameworkElement.HeightProperty, height);
Hope this helped you