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

BitmapImageConverter problem or what??

3 Answers 105 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Leos
Top achievements
Rank 1
Leos asked on 10 Aug 2011, 02:59 PM
Hi,
I have next code:
<telerik:DataFormDataField Label="{Binding Photo, Source={StaticResource res}}">
  <telerik:DataFormDataField.ContentTemplate>
    <DataTemplate>
      <Image Source="{Binding Photo, Converter={StaticResource bic}, Mode=TwoWay}"/>
    </DataTemplate>
  </telerik:DataFormDataField.ContentTemplate>
</telerik:DataFormDataField>
where "bic" is Telerik BitmapImageConverter and Photo is byte[] (readed with WCF.RIA from server database)
It is working fine,  JPEG image is correctly displayed.

But when I replace "Image line"  with:
<telerik:RadImageEditorUI Image="{Binding Photo, Converter={StaticResource bic}, Mode=TwoWay}" />

I got some strange exception and application crashes (!):
Message: Set property 'Telerik.Windows.Controls.RadImageEditorUI.Image' threw an exception.

I did plan to use this component for display photos from database and loading or saving them to disk :(

What is wrong?
Leos

3 Answers, 1 is accepted

Sort by
0
Accepted
Iva Toteva
Telerik team
answered on 10 Aug 2011, 05:09 PM
Hi Leos,

First of all, thank you for your interest in RadImageEditorUI.
To your question:
Unfortunately, with the current version of the control, you cannot bind the Image property of RadImageEditor or RadImageEditorUI directly, due to the fact that it is not a dependency property. However, you can create your own control encapsulating RadImageEditor or RadImageEditorUI and expose a dependency property that's suitable for your binding scenario. You can synchronize it manually in the appropriate events.
We have scheduled this behavior for revision and will implement some way for binding the image in the service pack in mid-September.

All the best,
Iva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Leos
Top achievements
Rank 1
answered on 10 Aug 2011, 09:32 PM
Hello Iva,
thanks for answer.

What event use to synchronize your and my Image after opening/changing image in your component?  How to get some info that (your) image was changed?

And two tips for you:
- please add IsReadonly property
This property, when binded (with converter) to RadDataForm  mode and readonly, allows display and save image to disk (if image displayed)  but disallows open or change image.  Now you have only Enabled property and this disables saving of displayed image.
- add button for clear/delete image to have chance save "no image" to data source .

Leos
0
Accepted
Iva Toteva
Telerik team
answered on 16 Aug 2011, 12:46 PM
Hi Leos,

You can use the CurrentImageChanged event of the ImageHistory object, which RadImageEditor keeps as a property. Here is an example of how this can be done:

this.ImageEditorUI.ImageEditor.History.CurrentImageChanged += History_CurrentImageChanged;
CurrentImageChanged is fired when the image currently viewed in the editor has changed, i.e. if a command has been executed on the image loaded in the editor or the image has been changed all together.
Therefore, you have to perform the following check in the event handler:
private bool hasImageBeenChanged;
void History_CurrentImageChanged(object sender, EventArgs e)
{
   ImageHistory history = (ImageHistory)sender;
   if (!history.CanRedo && !history.CanUndo)
   {
      hasImageBeenChanged = true;
   }
   else
   {
      hasImageBeenChanged = false;
   }
}

As for the other items on your list, we are considering adding an IsReadOnly property for the ServicePack in mid September.
When it comes to the clear/delete button, you can easily add a button by modifying the template of the control and using the methods from RadImageEditor's API.

Regards,
Iva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
ImageEditor
Asked by
Leos
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Leos
Top achievements
Rank 1
Share this question
or