Using DevExpress ChartControl and Data Grid in WPF - wpf

How to use Data Grid as data source, and show it to DevExpress ChartControl in WPF? Or, you have alternative solution, to show chart from data grid in WPF?

Although it is possible to bind the DevExpress ChartControl and GridControl to the same view model collection, you can also use the standard WPF binding syntax to link the GridControl to the ChartControl.DataSource property (DataSource="{Binding ElementName=grid, Path=SelectedItems}").
This approach is shown in the "Data Grid Charting" ChartControl demo module from the DevExpress Demo Center. In this case, the chart's layout is automatically updated based on the actual grid selection state.

DataGrid should not be a data source for your ChartControl.
I assume that you using MVVM pattern for WPF application.
If you don't know about MVVM please read:
MVVM: Tutorial from start to finish?
In short your DataGrid from "View" is bind to a data source from "ViewModel" and ChartControl should follow the same principle, it should be bind to a data source from "ViewModel" not DataGrid itself.
Its the same as asking how do I print document from my monitor (you could do this by scanning your monitor and printing :) ).
You don't connect you printer to you monitor in order to print, you use same document as "data source" from your hard drive to display it on monitor as well as print it on printer.

Starting from DevExpress version 15.2, Report Generator tool allows you to generate a report from the DevExpress Grid View.
See the Advanced Grid Printing and Exporting help topic for more details. However, this approach will not work for the standard DataGridView. In this case, you can either use the Report Wizard to bind a report to your DataGridView's data source and generate required layout. Alternatively, you can create the report layout manually. Review the approach described in the How to create a report dynamically article.
For specific to WPF, refer below documentation links:
Grid-Based Report Generation
Please try these solutions and let me know if any of them helps.

Related

Filtration for List view data upon List view Header column clicks in WINFORMS

I dont know whether this is possible or not, But i just want your suggestions on this ..
Here is what I would like to be able to do. Not sure if this functionality is built in or if I will need to use a combination of any controls/tools.
I want to be able to filter a listview data.. have it filter the listview accordingly on click of listview columns header.I want to be able to use checkboxes in dropdown of listview header column such that I can filter data easily.
Best Example: Control Panel-->Uninstall a Program ,Where a list of uninstall programs available in listview for computing filtration upon click of any header.
I want this in Windows Forms Applications C# Visual Studio 2010
If solution is possible, pls. share the site links or any free tools also as well.
Here is the same idea for a DataGridView http://www.codeproject.com/Articles/33786/DataGridView-Filter-Popup However, you would have to write the code to do the filtering as a winforms ListView does not supporting binding to a DataTable.
ObjectListView -- an open source wrapper around a .NET ListView -- supports filtering out of the box.

Recommended books for wpf custom control design-time features

I have some custom controls that I would like to make more 'user friendly' in Cider (VS wpf designer). I have red all the documentation in MSDN and some sites that I found through google , but I did not find answers to some simple questions :
How to set default values for the items that are created from a collection editor (like columns in datagrid, not drag-drop from toolbox)
How to generate XAML (like the datagrid dose when you click generate columns)
Please let me know if you know of any doc that goes into details such as those mentioned above.
Also if you know/have any custom controls with visible source code that have designer support (like Xceed or DevExpress) please share a link.
Recommended books:
1- www.amazon.com/Pro-WPF-2012-Presentation-Professionals
2- any book about Design Pattern like www.amazon.com/3-0-Design-Patterns-Judith-Bishop
3- MVVM
to add a column to data grid you don't need to generate xaml, there is a column collection you can add one by code behind
dataGrid1.Columns.Add(new DataGridTextColumn{ Header = "column1"});
read the first book well and you will be good
This an excellent and rare book that goes deep into custom controls development:
WPF Control Development Unleashed: Building Advanced User Experiences

What design pattern can be used for this scenario?

I am developing a WPF application, The below two being the major modules
The data is obtained from a service and there would be frequent updates after the initial startup.
The grid controls which display the data has to be dynamically created based on a configuration.
Which design pattern would best suit this problem. MVVM pattern does not fit here.
Any suggestions?
Thanks,
using this solution
WPF MvvM DataGrid Dynamic Columns
you can create the columns in your VM and have MVVM bind to both the column definitions and the data for the datagrid.
This is assuming that you need a lot of control over your columns and not just have the datagrid auto generate them from your itemssource binding

SilverLight like Datagrid Paging in WPF?

Currently I am searching for the best way for paginating the records in WPF datagrid.
I have found one best article which provide best way for paginating records in Silverlight over here.
See it provides also a fabulous demo.
Here is one screen shot.
But when I have trying it to implement it in WPF I could not implement it?
I could not found PagedCollectionView class and also could not found the alternative XAML code of the Silverlight code shows is below screen shot.
Could any one provide or suggest the best way for paginating the records in WPF
as like Silverlight?
You can grab the PagedCollectionView source code from here and compile it into your WPF project. I've done this for a WPF project in the past and it works just fine. However, you won't have the supporting types like DataPager, but it's easy enough just to write your own or throw some buttons on your view that page through the collection.
WPF DataGrid doesn't come with pagination by default. You have to have your own custom implementation. Here is a sample. The sample implements First/Previous as ViewModel commands, however I would advise you to move these commands as part of the control and make a custom DataGrid control that you can reuse across application.

Where can i find Free WPF controls

Is there any site available where I can find free WPF controls like Griview ? I am currently working on a complex project where I need a customizable WPF Gridview like telerik
You can use controls from the WPF Toolkit as well as Extended WPF Toolkit.
Have a look at the controls in AvalonControlsLibrary on code plex, it is having a DataGridView control apart from other controls. -
http://avaloncontrolslib.codeplex.com/wikipage?title=Home&ProjectName=avaloncontrolslib
DataGridView
DataGridView is a maybe a misleading name for this control. This control is far from being the same as the WinForms DataGridView (maybe someday it will J). Basically this control is a WPF ListView control but it is capable of auto generate the GridViewColumns for you. It generates the columns by looking at the objects’ properties. You can also specify how you generate the columns by decorating your properties with a custom attribute. For more information have a look at this post. http://marlongrech.wordpress.com/2007/09/01/listview-with-auto-generation-of-column-enable-disable-columns/
Similar SF question - Where can I find free WPF controls and control templates?
On codeplex.com and codeproject.com. However the best always cost money.

Resources