This article by Atul Gupta has sample code that covers several scenarios:
- Regular resource image binding to Source property in XAML
- Binding resource image, but from code behind
- Binding resource image in code behind by using Application.GetResourceStream
- Loading image from file path via memory stream (same is applicable when loading blog image data from database)
- Loading image from file path, but by using binding to a file path Property
- Binding image data to a user control which internally has image control via dependency property
- Same as point 5, but also ensuring that the file doesn't get's locked on hard-disk