This is a migrated thread and some comments may be shown as answers.

Binding Image using MVVM

3 Answers 206 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
cielo valdoz
Top achievements
Rank 1
cielo valdoz asked on 27 Mar 2012, 10:01 AM
Hi,

I would like to load images dynamically to the RadImageEditor but the image is not displaying.
The image was passed from another module then it will convert into an image.

<

 

 

telerik:RadImageEditorUI Margin="0" Name="RadImageEditorUI1" Image="{Binding ImagePath, Converter={StaticResource ImageConverter}}" SaveCommand="{Binding SaveImageCommand}">

 



CONVERTER:

Namespace Converter
  
    Public Class ImagesConverter
        Implements IValueConverter
        Private Shared ImageFolder As String = "Images/"
        Public Function Convert(value As Object, targetType As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
            Dim img As New BitmapImage()
            Dim imageEditor As New RadImageEditor
  
            If Not value Is Nothing Then
                'value = "EGS14272012143526640.png"
  
                img.UriSource = New Uri(ImageFolder & value.ToString, UriKind.Relative)
  
            Else
                Return Nothing
            End If
  
            Return img
        End Function
  
        Public Function ConvertBack(value As Object, targetType As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
  
        End Function
    End Class
End Namespace

Can anyone help me?

Thanks,
Cielo

3 Answers, 1 is accepted

Sort by
0
Mike
Telerik team
answered on 30 Mar 2012, 08:13 AM
Hi Cielo,

We tested that Image property binding works as expected on the side of the ImageEditor. The problem should be related to image converter. When debugging your Silverlight application you can check the debug output window if there are any errors related to the binding.

In this case we noticed that the return object of type BitmapImage and RadImageEditorUI expects RadBitmap for the property Image which might be the problem. You should create RadBitmap from the BitmapImage and return it instead. Let us know if the problem persists.

All the best,
Mike
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Muhammad
Top achievements
Rank 1
answered on 14 May 2013, 07:45 AM
can you please explain how can i do this convert bitmap to radbitmap

thanks in advance.
0
Ye
Top achievements
Rank 1
answered on 15 May 2013, 07:07 AM
byte[] contents;

 IImageFormatProvider importer = ImageFormatProviderManager.GetFormatProviderByExtension(formatExtension);
                if (importer != null)
                {
                    this.radBitMap = importer.Import(contents);
                    return true;
                }
here is an example that use telerik's format provider to convert byte arrays to radBitMap.

Tags
ImageEditor
Asked by
cielo valdoz
Top achievements
Rank 1
Answers by
Mike
Telerik team
Muhammad
Top achievements
Rank 1
Ye
Top achievements
Rank 1
Share this question
or