I am trying to use reporting tool. I have created sample project.
I need to know how to assign datasource in WPF file for report1.igr in below tag.
<
Thanks for help,
Jaydeep
Hi,
You can bind the data source defined in the report directly in the XAML using Bindings, like this:
<ig:XamReportViewer>
<ig:XamReportViewer.RenderSettings>
<ig:ClientRenderSettings DefinitionUri="MyNamespace.Orders.igr, MyAssembly">
<ig:ClientRenderSettings.DataSources>
<ig:DataSource TargetDataSource="Order_Detail"
ItemsSource="{Binding OrdersDataSource}" />
</ig:ClientRenderSettings.DataSources>
</ig:ClientRenderSettings>
</ig:XamReportViewer.RenderSettings>
</ig:XamReportViewer>
“Order_Detail” is the name of the data source defined at design-time.
You can see examples of this on pages 138 and 236-237 of the documentation (notice that when you install the CTP a PDF containing the documentation gets installed too).
You can also programmatically set a new RenderSettings configuration specifying the report you want to render and the data sources you want to use.
May be if you give me more information about what you are specifically trying to accomplish I can help you better.
Thanks,
Leo
Hi ,
Thanks for reply. I created report1.igr in WpfApplication and connected sql server (Datasource= SqlDataSource1) at design time. It's simple connecting NorthWind Database and showing Employee table.
Also added one MainWindow.xaml file . In xaml file ,added XamReportViewer control to show report from report1.igr.
I have following query
1) Can we show report in XAML file ?
2) Need to know ClientRenderSettings tag in XAML file so that I can show report1.igr in XAML file.
You should be able to show the report in the viewer without the need to bind the data source, using the following XAML.
<ig:XamReportViewer Name="xamReportViewer1">
<ig:ClientRenderSettings
DefinitionUri="WpfApplication1.Report1.igr, WpfApplication1" />
The ClientRenderSettings can be specified in the XAML (notice that you can also bind the DefinitionUri to a view model if you want) or you can set it in code, like this:
var settings = new ClientRenderSettings();
settings.DefinitionUri = "WpfApplication1.Report1.igr, WpfApplication1";
xamReportViewer1.RenderSettings = settings;
Not sure if this answers all your questions. Please tell me if you need anything else.
Thanks for reply.
I had used ClientRenderSettings tag and code is as follows. It is giving me error "Unable to find connection String for datasource SqlDataSource1"
XAML code as follows-
Window x:Class="WpfApplication1.MainWindow" xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" xmlns:ig="http://schemas.infragistics.com/xaml" xmlns:my
="clr-namespace:System;assembly=mscorlib">
<Grid>
<ig:XamReportViewer Height="311" HorizontalAlignment="Left" Name="xamReportViewer1" VerticalAlignment="Top" Width="503" DataContext="{Binding
}">
<ig:ClientRenderSettings DefinitionUri
="WpfApplication1.Report1.igr, WpfApplication1">
</Grid>
</
Window>
Thanks a lot,
That is weird. How did you exactly create the data source you are using in the report? Did you saved the connection string into the App.config? Do you have an App.config in your project? Does it contain the connection string SqlDataSource1?
Please follow the walkthrough “Creating a Simple Tabular Report” on page 141 of the documentation to check that you are not missing any step.
Thanks for having patience with me.
I created report1.igr in WpfApplication1 application only. So single application is there and no class library application.
I created SqlDataSource1 in report1.igr through wizard. Connection string is not mentioned in App.xaml. Do I need mention connection string for SqlDataSource1 in App.xaml and how?
when I preview report1.igr indenpendently, it is showing data properly. Only viewing through xaml file give error mentioned in last post.
Thanks once again,
It's working fine. Thanks a lot for all your help.
I take a look at the solution you sent me. The problem is that the “app.config” file is not included in the project. The file is present in the project folder (with the connection string) but somehow it has been excluded from the project itself. You should add it back. At runtime NA Reporting will look for that file in order to get the connection string. At design time it is getting the connection string from the Settigs. That is why it’s working.
Also you should remove the following lines from your xaml.
<ig:DataSource TargetDataSource="sqlDataSource1" />
Specifying a data source through the viewer API is meant for scenarios where you want to swap the data source at runtime, which I think is not the case. Also notice that if you would want to swap the data source you would need to specify the ItemsSource property of the ig:DataSource, in addition to the TargetDataSource.
Once you add the “app.config” back, remove the xaml I mentioned and rebuild the project the problem should be fixed.
Please note that the DataContext={Binding} that you specified in several places are not needed.
Please tell me if you need any more.
My question was regarding the “App.Config” file, not the “App.xaml” file. The app.config file is a configuration file where the connection string should have been stored when you first create the data source using the Wizard. Do you have that file? Does it contains the connection string you are using?
Can you send me the solution so I can analyze what is happening? (lrodriguez at infragistics.com)
I have WpfApplication so I have App.xaml. I am using connection defined in server explorer.
I haven't code anyhting yet. Just created connection using server explorer and drag fields from there.
Want to show in WPF file using XamReportViewer.
Thanks for guidance.
When you create a new data source the Data Source Creation Wizard by default will store the connection string in the App.config file. You should have an App.config file in your project containing the connection string. Do you have it?
Are you using a connection defined in the Server Explorer?