Page 1 of 2
Hot to bind FieldValue to a Image Control??
Posted: Fri Jun 10, 2011 1:31 am
by lowence
I have a bussnessobject with a Image Field.
Bind the Image Field to a Image Control.
But ,it's nothing appear.
How can i do it??
Hot to bind FieldValue to a Image Control??
Posted: Fri Jun 10, 2011 8:01 am
by Andrew
Hello,
The way you try to do is impossible. Binding Objects is not supported there.
Thank you.
Hot to bind FieldValue to a Image Control??
Posted: Fri Jun 10, 2011 9:00 am
by lowence
I see the Images Demo of C# Samples (ClientServer).
It show the Image Control can be bind to a byte[] type column.
But when i try use the same way,it not run fine??
Why?And is there some another way??
Hot to bind FieldValue to a Image Control??
Posted: Fri Jun 10, 2011 10:42 am
by Andrew
Hello,
Please send us an example of your application with an example Business Objects. We will see what you're doing wrong and try to help you.
Thank you.
Hot to bind FieldValue to a Image Control??
Posted: Fri Jun 10, 2011 10:18 pm
by lowence
TheDataSource:
public class ImageDemo
{
public string Name { get; set; }
public object Image { get; set; }
public static ImageDemo GetItems()
{
// a local image
var bitmap = new BitmapImage(new Uri("/ReportingHelper;component/Images/OnePage.png", UriKind.RelativeOrAbsolute));
// convert to base64 string
string str =GetBase64Image(bitmap); // i try use StiImageConverter.ImageToPackedString(bitmap) or StiImageConverter.ImageToString(bitmap), but the method throw a null point exception.
// return the object
return new ImageDemo() { Name = "Zhang San", Image = str };
}
}
Application Method:
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ReportingHelper.2.mrt");
StiReport report = new StiReport();
report.Load(stream);
report.CalculationMode = StiCalculationMode.Interpretation;
Type type = typeof(ImageDemo);
report.RegBusinessObject(type.Name, type.Name, ImageDemo.GetItems());
report.Render();
this.PreviewControl.Report = report;
}
The Report Mrt, I bind a DataColumn to a StiImage Control the Code snippets:
[216:216:216]
8.8,0.6,7.4,6.4
p.Page1
ImageDemo.Image
Image1
True
Hot to bind FieldValue to a Image Control??
Posted: Mon Jun 13, 2011 2:31 am
by Anton Lozovskiy
Hello,
We create an example for you, please see.
Thank you.
Re: Hot to bind FieldValue to a Image Control??
Posted: Thu Jun 05, 2014 2:57 pm
by yasminteles
Hello.
This example error occurs on the line below:
Code: Select all
string str = StiImageConverter.ImageToString(bitmap as BitmapImage);
Error: Object reference not set to an instance of an object.
I'm with Stimulsoft Reports.Silverlight version 2014.2.1905 from 05/30/2014
Att
Re: Hot to bind FieldValue to a Image Control??
Posted: Fri Jun 06, 2014 8:03 am
by Alex K.
Hello,
Can you please send us a sample project which reproduce the issue for analysis.
Thank you.
Re: Hot to bind FieldValue to a Image Control??
Posted: Fri Jun 06, 2014 12:29 pm
by yasminteles
Hello.
My errors with images in reports: Images in project and Images in database.
The example
http://websl.stimulsoft.com/?reportname=Images, the image already converted and the data source is an xml file
Code: Select all
servicoWCF.ConsultaRelatorioAsync();
void servicoWCF_ConsultaRelatorioCompleted(object sender, ConsultaRelatorioCompletedEventArgs e)
{
if (e.ncErro == null && e.Result != null)
{
Data dataRelatorio = new Data();
Data.ncConteudoCollection conteudoColecao;
Data.ConteudoItem conteudo;
foreach (ncRelatorio1 item in e.Result)
{
conteudo = new Data.ConteudoItem();
//Name
conteudo.Info03 = item.Info2;
//Company
conteudo.Info04 = item.Info3;
//*********************************************************************************
//doubt 1 - Image is in project (Company Logo)
BitmapImage bitmapImage = new BitmapImage(new Uri("/nc.Relatorio;component/Recursos/Imagens/Logo.png", UriKind.Relative));
//Error when trying to convert with StiImageConverter (Error: Object reference not set to an instance of an object)
byte[] image = StiImageConverter.ImageToBytes(bitmapImage);
//conteudo.Info49 - byte[] type in Stimulsoft Businnes Object. I am using the DataColumn property for the image component.
conteudo.Info49 = image;
//The example http://forum.stimulsoft.com/viewtopic.php?f=11&t=4498 - 1067.SilverlightApplication1.zip also contains this error
//*********************************************************************************
//doubt 2 - Image in database is not displayed in the report, only Name and Company
//Commenting on the previous error
//item.Info50 - byte array with person's photo
//conteudo.Info50 - byte[] type in Stimulsoft Businnes Object. I am using the DataColumn property for the image component.
conteudo.Info50 = item.Info50;
//*********************************************************************************
dataRelatorio.Conteudo.Add(conteudo);
}
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
StreamReader reader = new StreamReader(a.GetManifestResourceStream("nc.Relatorio.Relatorios.NR0101.mrt"));
StiReport report = new StiReport();
report.Load(reader.BaseStream);
reader.Close();
reader.Dispose();
report.CalculationMode = StiCalculationMode.Interpretation;
report.RegBusinessObject("Data", "Data", dataRelatorio);
report.Render();
report.Show();
}
}
Please help me.
Thankyou
Teles
Re: Hot to bind FieldValue to a Image Control??
Posted: Fri Jun 06, 2014 8:00 pm
by yasminteles
Hello.
About load image in database I resolved the problem, but I need load image in project.
Code: Select all
servicoWCF.ConsultaRelatorioAsync();
void servicoWCF_ConsultaRelatorioCompleted(object sender, ConsultaRelatorioCompletedEventArgs e)
{
if (e.ncErro == null && e.Result != null)
{
Data dataRelatorio = new Data();
Data.ncConteudoCollection conteudoColecao;
Data.ConteudoItem conteudo;
foreach (ncRelatorio1 item in e.Result)
{
conteudo = new Data.ConteudoItem();
//Name
conteudo.Info03 = item.Info2;
//Company
conteudo.Info04 = item.Info3;
//*********************************************************************************
//doubt 1 - Image is in project (Company Logo)
BitmapImage bitmapImage = new BitmapImage(new Uri("/nc.Relatorio;component/Recursos/Imagens/Logo.png", UriKind.Relative));
[size=150][color=#FF0040] //Error when trying to convert with StiImageConverter (Error: Object reference not set to an instance of an object)
byte[] image = StiImageConverter.ImageToBytes(bitmapImage); [/color][/size]
//conteudo.Info49 - byte[] type in Stimulsoft Businnes Object. I am using the DataColumn property for the image component.
conteudo.Info49 = image;
//The example http://forum.stimulsoft.com/viewtopic.php?f=11&t=4498 - 1067.SilverlightApplication1.zip also contains this error
dataRelatorio.Conteudo.Add(conteudo);
}
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
StreamReader reader = new StreamReader(a.GetManifestResourceStream("nc.Relatorio.Relatorios.NR0101.mrt"));
StiReport report = new StiReport();
report.Load(reader.BaseStream);
reader.Close();
reader.Dispose();
report.CalculationMode = StiCalculationMode.Interpretation;
report.RegBusinessObject("Data", "Data", dataRelatorio);
report.Render();
report.Show();
}
}
Please, help me.
Thank's