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

how to bind an image to RadImageEditorUI in WPF?

2 Answers 271 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Enric
Top achievements
Rank 1
Enric asked on 09 Sep 2013, 09:58 PM
hi there,

I'm loading a bunch of JPG files in one ListBox and then when the final user do doble-click mouse event my aim is just load the one JPG into Telerik control.
How can I do that??


Private Sub ListBox_MouseDoubleClick(sender As Object, e As MouseButtonEventArgs)
 
       Dim s As String = ""
 
       BodyWorkAndPaintingTool.?????????????  = TryCast(sender,ListBox).Items(0).ToString
   End Sub


  <telerik:RadImageEditorUI x:Name="BodyWorkAndPaintingTool" ContextMenuOpening="BodyWorkAndPaintingTool_ContextMenuOpening" Grid.ColumnSpan="4" Margin="10,49,33,10" Grid.Row="1" Grid.RowSpan="4">
            <telerik:RadImageEditorUI.ImageToolsSections>
                <telerik:ImageToolsSection Header="{Resx DisenadorBlur}"  >
 
                    <telerik:ImageToolItem ImageKey="Resize" Text="Resize" Command="commands:ImageEditorRoutedCommands.ExecuteTool">
                        <telerik:ImageToolItem.CommandParameter>
.....
.....
.....

Thanks in advance,

2 Answers, 1 is accepted

Sort by
0
Enric
Top achievements
Rank 1
answered on 10 Sep 2013, 01:22 PM
Hi,
Primary platform is Windows 7 Ultimate 64 bit, Vs Studio 2012 ultimate with the last SP, Framework 4.5
I've got referenced in my references: C:\Program Files (x86)\Telerik\RadControls for WPF Q1 2013\Binaries\WPF45\telerik.windows.controls.dll



Well, think I found the way to do that but I get an error when debugger reach this line:

Dim radbitmapet As New Telerik.Windows.Media.Imaging.RadBitmap(fluxeaescriure)


Code-behind:

Dim bmpIma As New BitmapImage
     bmpIma.BeginInit()
     bmpIma.UriSource = New Uri("c:\puesto\DSCN3015.jpg", UriKind.RelativeOrAbsolute)
     bmpIma.EndInit()
 
 
     Dim fluxeaescriure As New WriteableBitmap(bmpIma)
 
     Dim radbitmapet As New Telerik.Windows.Media.Imaging.RadBitmap(fluxeaescriure)
 
     Me.BodyWorkAndPaintingTool.Image = radbitmapet


I don't get the point about the error...(in spanish):

"RadBitmap.cs not found"

Buscando origen de 'c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\ExportExtensions\System.Windows.Media.Imaging\RadBitmap.cs'. Checksum: MD5 {2c d2 ca 6 a 1b 85 d5 4e 9c d7 46 81 cc f5 96}
El archivo 'c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\ExportExtensions\System.Windows.Media.Imaging\RadBitmap.cs' no existe.
Buscando 'c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\ExportExtensions\System.Windows.Media.Imaging\RadBitmap.cs' en los documentos de script...
Buscando en los proyectos 'c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\ExportExtensions\System.Windows.Media.Imaging\RadBitmap.cs'.
El archivo no se encontró en un proyecto.
Buscando en el directorio 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src\'...
Buscando en el directorio 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src\vccorlib\'...
Buscando en el directorio 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\src\mfc\'...
Buscando en el directorio 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\src\atl\'...
Buscando en el directorio 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include'...
Buscando en el directorio 'C:\'...
La configuración de archivos de código fuente de depuración para la solución activa indican que el depurador no pedirá que el usuario busque el archivo: c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\ExportExtensions\System.Windows.Media.Imaging\RadBitmap.cs.
El depurador no puede encontrar el archivo de código fuente 'c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\ExportExtensions\System.Windows.Media.Imaging\RadBitmap.cs'.

0
Petya
Telerik team
answered on 12 Sep 2013, 04:54 PM
Hello,

I am not quite sure I properly understand your scenario.

First, please note that the required assembly references in order to use RadImageEditorUI are listed here.

When it comes to binding, the Image property of RadImageEditor is of type RadBitmap. In order to create a RadBitmap based on Uri you can use one of the format providers shipped with the control. 

For example, here is how to create a stream and import it with one of the format providers. Note that in this case uri is the Uri object you want to pass and extension is the extension of the respective file.
using (Stream stream = Application.GetResourceStream(new Uri(uri, UriKind.RelativeOrAbsolute)).Stream)
{
    IImageFormatProvider formatProvider = ImageFormatProviderManager.GetFormatProviderByExtension(extension);
    this.ImageEditorUI.Image = formatProvider.Import(stream);
}

I hope this helps! If I misunderstood your scenario please get back to us with additional details.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
General Discussions
Asked by
Enric
Top achievements
Rank 1
Answers by
Enric
Top achievements
Rank 1
Petya
Telerik team
Share this question
or