Windows リソースに写真があります。
<Window.Resources>
<BitmapImage x:Key="Image1" UriSource="../Resources/MyImages/Image1.png" />
<BitmapImage x:Key="Image2" UriSource="../Resources/MyImages/Image2.png" />
<BitmapImage x:Key="Image3" UriSource="../Resources/MyImages/Image3.png" />
</Window.Resources>
それらの名前は、モデルの enum オブジェクトにある名前と一致します。
private ImagesEnum _currentImage;
public ImagesEnum CurrentImage
{
get { return _currentImage; }
set
{
if (_currentImage!= value)
{
_currentImage= value;
NotifyPropertyChanged("CurrentImage");
}
}
}
列挙型:
public enum ImagesEnum
{
Image1,
Image2,
Image3
}
リソースの名前を列挙型オブジェクトにある名前にバインドしたい。
このようなもの:
<Image Source="{StaticResource {Binding CurrentImage}}" />
これを行う方法はありますか?