2009-07-16 14 views

答えて

1

ソースは、このように画像に文字列を変換する値コンバータを使用してみてください、BitmapImageのを必要とします。

public sealed class ImageConverter : IValueConverter 
{ 
    public object Convert(object value, Type targetType, 
          object parameter, CultureInfo culture) 
    { 
     try 
     { 
      return new BitmapImage(new Uri((string)value)); 
     } 
     catch 
     { 
      return new BitmapImage(); 
     } 
    } 

    public object ConvertBack(object value, Type targetType, 
           object parameter, CultureInfo culture) 
    { 
     throw new NotImplementedException(); 
    } 
} 
<Image> 
    <Image.Source> 
     <BitmapImage UriSource="{Binding ElementName=txtImage, Path=Text, Converter=...}" /> 
    </Image.Source> 
</Image> 

参考:Image UriSource and Data Binding

+0

これを機能させるには、コンバータを手続き型コードでデコードする必要がありますか? – Johnathan1

+0

コンバータは、リソースセクション(xaml)で宣言する必要があります。たとえば、Window.Resources –

+0

ありがとうございます。 – Johnathan1

関連する問題