+5  A: 

WPF uses an implicit type converter to convert the xaml string to the expected type. In code you are statically bound by the object type... If you look at the example here it shows how to set the source property to a BitmapImage that is generated from a local uri programatically.

Quintin Robinson
+2  A: 

you will probably need to do something like this

Uri i = new Uri("images\Thing.png");

keep in mind that you need to use a \ not a / for a windows file system

Take a look here

MasterMax1313