Hi
I created a class with some some attributes, i created an ObservableCollection of this class and want to print this.
Bur when i don't know how to set this class as DataSource .
Could you please help me in this.
Thanks
Hi,
you misunderstand my question. Your sample shows how to bind a single datasource, I want to bind to a collection of datasources.
In the viewmodel, it would be like IEnumerable<DataSource> DataSources
Best regards
Mathias
You can bind the DataSource property to any collection. If you bind it to a collection property in your view model it will work (as long as the structure of the data source used to define the report matches the structure of the data source passed at runtime).
The binding is done as shown above in this thread.
i.e.
<ig:XamReportViewer>
<ig:XamReportViewer.RenderSettings>
<ig:ClientRenderSettings DefinitionUri="{Binding DefinitionUri}">
<ig:ClientRenderSettings.DataSources>
<ig:DataSource TargetDataSource="Person" ItemsSource="{Binding Persons}" />
</ig:ClientRenderSettings.DataSources>
</ig:ClientRenderSettings>
</ig:XamReportViewer.RenderSettings>
</ig:XamReportViewer>
Hope it helps.
Best,
Leo
Hello,
is it possible to bind the DataSources Property to a ViewModel ...
like <ig:ClientRenderSettings DefinitionUri="{Binding DefinitionUri}" DataSources="{Binding ... }" >
Hi thanks for answer .. i will try and let u know ..
bye
thanks again
If you want to use a collection as a Data Source, you could use the Object Data Source.
For example, consider the following class:
public class Person
{
private static int Seed = 10;
public Person()
var value = Seed++;
Name = "Name" + value;
Age = value;
}
public string Name { get; set; }
public int Age { get; set; }
// It could be an ObservableCollection too
public static IEnumerable<Person> GetSampleData()
return new List<Person>
new Person(), new Person(), new Person(),
};
Just create a DS based on the GetSampleData method, drag&drop it to the report, hit preview and you should see the six persons being rendered as a table.
At runtime you can bind the data source to a collection containing the actual data you want to render, e.g. you can bind the data source to a collection in your view model.
<ig:ClientRenderSettings DefinitionUri="MyNamespace.MyReport.igr, MyAssembly">
<ig:DataSource TargetDataSource="Person"
ItemsSource="{Binding Persons}" />
Hope it clarifies.
Please tell me if you need something else or you have any problem.
Thanks,