Using Powerful Survey Generator In Wpf Applications.
At the moment new developing technologies appear almost any day. New technologies give developers with better abilities designed to construct applications with more stylish user interface and prolonged functionality. One of many of these technologies is WPF. A main advantages are usually:
1. Use of DirectX being technology for representing graphics instead of found in Windows Forms plus out of date GDI. It permits displaying of influences and complicated animation along with quite high performance.
Only two. Work can be easily partioned between designers plus developers. WPF has a reduced amount of limitation for web designers who can quickly put in place all interface variables: from buttons to help tables.
3. Different class structure, variable properties and gatherings.
4. Ability to cultivate applications using markup along with code of the selection part. Markup (XAML language) is commonly employed to implement job application appearance and practical part is identified in any .Net agreeable programming language.
6. WPF contains a rich range of panels, and it reduces time and effort required to situation elements on the create, as they cover most of necessary variants.
Using spite of all rewards, there are some problems with WPF; a lot of convenient handles and tools focus on Windows and the application of these tools streamlines development of high-quality packages. And developers simply can't use these tools for WPF by just placing them all on the form. Introduction of controls with similar abilities takes quite a lot of time period as their development for the purpose of Windows Forms would have taken several years. On the contrary it isnt reasonable so that you can refuse using them in any way. That is why it is possible to implement any Windows Methods controls (Control should mean classes handed down from System.Your windows program.Forms.Control inside WPF along with new technologies features. There is a special container System.Home windows.Forms.Integration.WindowsFormsHost chose to use Windows Creates controls on WPF sites. In order to use this element, you need to do the following steps:
1. Create latest WPF application
2. Boost your workers project a mention of the the WindowsFormsIntegration dll. It will get you access to the WindowsFormsHost container
Three. Add to the project the reference to the dll made up of Windows Forms power.
4. Place WindowsFormsHost feature onto WPF page.
4. Add WindowsForms element into your child elements of that WindowsFormsHost.
After you go through all the steps, you will be able to utilise any WinForms control at the WPF page delivering similar functionality as on Windows forms, probably with slight disadvantage. To have an ability to try to find this control belonging to the window code-behind file it's important to know its a:Name attribute. You then will be able to apply to a control by their name from code.
Let us consider using settings from the .Net ModelKit Place library on WPF articles. The library features wide abilities to make reports, charts, rotate tables, gauges, for example. It is developed for House windows Forms and it is likewise possible to use it during Web and Silverlight applications, but none of the aspects can be used directly with WPF. So, lets see how to use WindowsFormsHost for some belonging to the components included in the suit.
We will create a uncomplicated report with the use of compound included into the .Get ModelKit Suite library. The actual report will be displayed on the WPF page. To meet this task you need to have the following steps:
Come up with WPF project
Add records to PerpetuumSoft.Reporting and even PerpetuumSoft.Framework dlls
Add the actual UserControl element to the challenge. This element is really a wrapper for report features.
Run Tabels.Columns building editor, add A couple columns to the dinner table: Name and Phone.
Location ReportManager onto the form. This approach element is used to store information on report email templates. It is possible to set computer data sources using this element.
Double click on the ReportManager running its editor. Drive to the Data sources navigation bars.
It is necessary to add a data source. Click the Include button. In the appeared window, you need to placed data source name and choose the data source as well from the list. Go with dataSet1.Customers table being a data source value.
Click the New document control key in the report fashionable and in the came out window select Traditional report. Report wizard will run.
Head over to Reports tab, contribute new InlineReportSlot and click the actual Run Designer link to run report design designer.
Click the Brand new document button during the report designer and also in the appeared pane select Standard record. Report wizard might run.
Press the particular Add data switch to add a new department, select Customers.Table as a data source plus move all for sale fields from All domains to Visible industries. After all the actions are finished, wizard should look like it is shown in the photograph.
Add to the handler about OnLoad event of the UserControl rule of filling statement data source. For example, you may use the following code:
DataRow strip = dataTable1.NewRow();
row["Name"] = Velupe Leslie;
row["Phone"] = 613-442-7654;
dataTable1.Series.Add(row);
row = dataTable1.NewRow();
row["Name"] = Fisher Pete;
row["Phone"] = 401-609-7623;
dataTable1.Rows.Add(line);
row = dataTable1.NewRow();
row["Name"] = Brown Kelly;
row["Phone"] Equals 803-438-2771;
dataTable1.Rows.Add(line);
After you added this valuable code, you need to insert code to prepare a report. You can do it using ReportSlot.Prepare method.
inlineReportSlot1.Create();
Place ReportViewer onto the UserControl. This element is used to show off reports. It is necessary to put its Source building to the required InlineReportSlot.
Combine namespace containing UserControl to the XAML markup in the xml window:
xmlns:userControl=clr-namespace:RSSforWPFWithUserControl
Add all the WindowsFormsHost element to the variety by placing these code into the bottle body:
Add UserControl to the content:
Run application and see the result.
Its preferable to execute statistics preparation and record building on the UserControl. It allows using all available report capability, such as DesignTime Designer, auto saving of reviews in the application passcode, binding to information sources, etc.
Although besides this choice, there is another way to make use of Windows controls inside WPF. It is possible to place these sort of elements directly throughout WindowsFormsHost. There are some limitations using this type of approach.
In order to view reports, it is necessary set ReportViewer onto WPF page. It is possible using WindowsFormsHost element. Nonetheless here you will encounter a problem of how to form and edit document templates and connect to data sources. It's impossible to place ReportManager into WPF page as we used ReportViewer, as it is a descendant on the System.ComponentModel.Component course. The problem can be fixed in the following solution.
In spite it is unachievable to run ReportDesigner in design time to edit evaluations, there is always an ability to work it in playback, using the ReportSlot.DesignTemplate method. ReportSlot is formed dynamically in this case. After you generated all necessary modifications to the report template, it is possible to save the software to a file. That file represents a real usual xml file. There's two way of how to use the application. The first one is to use InlineReportSlot. In this situation you can just copy xml cord from the template submit and set this sequence as a DocumentStream property cost. It is possible to use FileReportSlot as well as in this case it is just required specify path to your file.
There is also a issue with data sources. If you work with data sources built into a template, there aren't problems; you can make use of them as you achieved it on Windows forms. If it is impossible align data source in this way, you could make ReportManager dynamically and add facts sources there. Database can be added making use of the Add function of the ReportManager.DataSources collection. You can use the following code:
reportManager.DataSources.Add(dataSourceName, dataSourceObject);
Consequently, using the solutions referred to in the article offers ability to use any kind of Windows Forms manage in WPF projects in some cases with slight constraints. But in spite in all limitations, this capacity is actual but it will stay actual till equivalent controls are created completely on WPF.
|
0 comments:
Post a Comment