I work with Winforms, CAB, C # and Infragistics. I am trying to work with MVP with my WCF backend.
In my presenter, I have My Model, let me call it the DataContract Agreement. This data contract contains many attributes:
... [DataMember] public byte[] PVImage { get; set; } [DataMember] public byte[] OntwerpImage { get; set; } [DataMember] public Decimal WattpiekPrijs { get; set; } ...
You will notice that the image is stored as byte []. I bind these attributes to the controls of my user control:
BindingHelper.BindField(_ultraPictureBoxPV, "Image", _bindingSource, "PVImage"); BindingHelper.BindField(_ultraPictureBoxOntwerp, "Image", _bindingSource, "OntwerpImage");
BindingHelper simply adds a BindingContext to the specified controller (control.BindingContext.Add (...)).
In any case, the problem is: the data contract contains the image as a bytearray, while I snap to the image. This makes the attribute remain โnullโ because it does not want to put the image in a byteArray;)
I tried playing with him, but I think I have two options:
Can I try to use a kind of converter? Therefore, when an image is inserted, it is transmitted as a byteArray instead of the image in Model (= data binding).
I can remove the binding and make an event when the form is โsubmittedโ, and convert the image to byteArray and populate the model. (= no data binding)
TL DR; Do you know a way to "convert" an image to bytes when it is transferred to data binding?
Hope my question is clear! thanks for the help
source share