Is it possible to have an image that its source in the datasource
e.g. the object the report is running against provides an imagesource property that the image control can bind to?
Hi,
Currently you can bind the Image property to a byte array containing the actual image bytes. That array could be obtained for the data base for example. Binding the Image to a property that returns an ImageSource is not possible today.
Thanks,
Leo
Can you give an example of how to bind an image to a byte array? I have rendered my image to a byte array, and I have added that to a List of DataSourceValue's, so when I create my IServerExporter I assign that list to the DataSources property.
But what I don't know is exactly how to specify the image binding. I've been looking for examples, but haven't found anything so far. I tried the following, but nothing appeared:
<
Image BorderThickness="0px" BorderColor="White" Background="White" ImageUrl="=ColumnPercentagePieChartImage1" Left="0pt" Top="0pt" Width="300px" Height="300px">
Image.Bindings>
Binding Source="=ColumnPercentagePieChartImage1" Target="ImageUrl"/>
</
Image>
In my case, ColumnPercentagePieChartImage1 is the name of the data source. But clearly that's not cutting it.
I'll keep playing with it.
Mike
Hi Michael,
If the you are using byte[] try using: Target="ImageBytes"
e.g:
<Image BorderThickness="1px" BorderColor="DarkGray" Background="Transparent" ImageName="=Fields.Image" Left="600px" Top="23px" Width="NaNpx" Height="NaNpx" Cell.Row="1" Cell.Column="3"> <Image.Bindings> <Binding Source="=Fields.Image" Target="ImageBytes" /> </Image.Bindings> </Image>
That should do the trick.
Regards,
Miguel.
Thanks Miguel. That seems to have done it.
For the time being you should wrap the image field with an object and bind the report's image control as shown above.
Here is a handy sample for displaying Employee's images from an Object DS, your wrapper would play the same role the Employee class does in this case.
e.g.
In C#:
public class Employee{ public string Name { get; set; } public byte[] Image { get; set; }}
public class EmployeesDataSource { private List<Employee> _employeeCollection;
public IEnumerable<Employee> GetPeople() { // Load Data _employeeCollection = new List<Employee> { new Employee { Name = People.Guy01Name, // Image as byte[]; Image = People.GUY01, }, }; return _employeeCollection; }
Miguel
Thanks for the quick response!
However, it's still not working. Your exmaple binds to a field (=Fields.Image), but in my case, the byte array is in it's own separate data source. I know the name of the data source, and the value is a byte array (byte[]).
How do I specify the whole data source? With no property?