cat_userParticipantOctober 18, 2017 at 4:47 pmPost count: 2
I have a requirement to generate columns dynamically using MVVM pattern. Another requirement is to show parent child relationship. I looked at the example – TreeGridflowView – but the hierarchy should be generated dynamically as well as the depth of the hierarchy will depend on data fetched from database. Is it possible to create an example showing both these requirements?Fawzi [Xceed]MemberOctober 20, 2017 at 5:42 pmPost count: 722
While I don’t have a sample which implements your requirements, you may look at the “MVVM” sample project which comes along with the Xceed package for detailed information on how to use the grid with MVVM. The sample can be found, by default, at the following path on your machine:
C:\Xceed Samples\Xceed DataGrid for WPF v6.4\CSharp\MVVMcat_userParticipantOctober 24, 2017 at 4:20 pmPost count: 2
I was able to create dynamic columns using ICustomTypeDescriptor which is in LargeDataSets example. Based on my requirement I have a tree in my first column whose objects could also be shared by multiple parent tree node.
If I make changes to fixed properties, they reflect to all other shared instances. But changes made to dynamic properties do not update to other instances. Is there a way to databind them?Diane [Xceed]ModeratorOctober 31, 2017 at 5:41 pmPost count: 1353
You may not be able to do what you wish using MVVM. To create columns dynamically, it must be done in code-behind. Unfortunately, these columns will have to be inserted in the column collection (DataGridControl.Columns). In order to do this, you will need either a reference to the DataGridControl instance, or the grid’s column collection instance. The DataGridControl.Columns collection is a read-only property and cannot be set by the user.
Either way, you will need to have access to the grid instance somehow, which I think is against the MVVM philosophy. The same problem arises while building the hierarchy. The hierarchy is built from master-detail. You will have to create DetailConfiguration and insert these into the DataGridControl.DetailConfigurations or DetailConfiguration.DetailConfigurations collections. You may also have to create DetailDescription and insert them in the DataGridCollectionView.DetailDescriptions collection.
- You must be logged in to reply to this topic.