Architect's Log

I'm a Cloud Architect. I'm highly motivated to reduce toils with driving DevOps.

WPFアプリケーションに組み込んだリソースをコードから参照する

以下のエントリーで、アプリケーションに組み込んだリソースをコードから参照します。
リソースをWPFアプリケーションに組み込む - プログラマーな日々
リソースを3種類の方法でWPFアプリケーションに組み込みます。 ...

MainWindow.xaml

<Window x:Class="HelloWorld.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="900">
    <StackPanel x:Name="StackPanel1"  Orientation="Horizontal">

    </StackPanel>
</Window>

MainWindow.xaml.cs

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;

namespace HelloWorld {
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();

            {
                Image img = new Image();
                img.Source = new BitmapImage(new Uri("images/content-image.jpg", UriKind.Relative));
                StackPanel1.Children.Add(img);
            }
            {
                Image img = new Image();
                img.Source = new BitmapImage(new Uri("images/resource-image.jpg", UriKind.Relative));
                StackPanel1.Children.Add(img);
            }
            {
                Image img = new Image();
                img.Source = new BitmapImage(new Uri("images/embedded-image.jpg", UriKind.Relative));
                StackPanel1.Children.Add(img);
           }
        }
    }
}

アプリ実行

EmbeddedResourceで組み込んだ画像だけ参照できませんでした。方法がわかったら追記します。