It is very easy to load an image in XAML:
<Image Source="Resources/Images/pic.png" />
I wonder is there a simple way to do it programmatically? I've found the following solution (spent half a day):
Uri uri = new Uri("pack://application:,,,/" +
Assembly.GetExecutingAssembly().FullName +
";component/Resources/Images/pic.png", UriKind.Absolute);
BitmapImage img = new BitmapImage(uri);
Image im = new Image();
im.Source = img;
Grid.SetColumn(im, 1);
grid.Children.Add(im);
As to me, it looks ugly and very COM-like. It has no flavor of .NET FCL (carefully and thoroughly thought over) class library. Why should we use strings like: "pack:...", anyway? Enumerations are much better (a kind of Resources.Local).
I hope there is more elegant way to do the job. Thank you.