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
Related
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.
I need to build our future business applications with WPF using MVVM.
My typical application consists of several windows/tab pages with grids and form style windows. Both edit windows and grid windows can be different depending on the logged in user, so most of them will be built datadriven.
And I'm trying to write as few code as possible, as not written code is the only one to be guaranteed error free .
So, now my question: how to structure the entire thing?
The View is clear to me - is is built using XAML or by code.
The ViewModel should contain the business logic and the validation rules and should let feed the View the data, and should contain the commands for the actions.
So, where to put the data? A select returns a DataTable. Should this datatable exposed through the ViewModel to the View for the grid windows?
And for the form windows? Should the single DataRow exposed trough the ViewModel to the View?
Are there other helper or intermediate classes needed?
Thank you for any useful suggestion!
Wolfgang
Its best way to go with WPF and MVVM,
I suggest before you start go thru the basics of MVVM. for your reference you can understand better here
The preferred UI paradigm in WPF is to have tab controls and grids in a single window, something like this:
You don't have to stop there, you can nest them as deeply as you need to for the sake of clarity.
I don't have any code currently, but I need to make an admin screen for my WPF 4.5 project that is using MVVM Light. The design has a left hand column with all of the objects you can edit. The right hand side is a data grid with all the values, columns, etc that are currently in the database. I was just curious what the best way to architect this would be. I had imagined using a singular datagrid that you can switch the datacontext on but I am still fairly new to WPF and MVVM Light. One thing I know for sure is that we do not want to use Auto Generate Columns because each table has different columns and we do not want to use the column names from the database.
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.
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.