I saw some posts that seem to deal with this, but after testing... I didn't see any solution.
I have a hierarchical datagrid with only one FieldLayout.
It represents folders that can contain folders that can contain folders... and so on.
My data call is a self recursing class.
I want to display for each folder :
- 1 icon + name column
- 1 comment column
My problem is that, as is, the comment columns are not alignated : for each level, there is an offset.
I'd like to have the comment columns alignated whateven the level.
Is there a way to do this ?
Hi,
Please let me know if you have any further questions about the MultiBinding.
The MultiBinding is passing multiple values back to the converter, the count of child rows and the IsExpanded property, so that the converter can determine what text value to return.
Let me know if you have any questions
Thank you. I tryed somthing like this... but it didn't work.
I believe I was missing the multibinding thing...
In order to force the expansion indictor to change automatically when children are added to the collection you can implement INotifyPropertyChanged on the data object (RowViewModel) and then add an event handler for the ListChanged event of the Child Rows. Whenever this event is fired you can send change notification for the ChildRows property.
With the property changed notification implemented you can then change the style and the associated Expansion indicator converter to use a multi Binding / multi converter which will listen for changes to the ChildRows collection via the Count property and also bind to the is Expanded property for the row.
Please see the attached sample.
Let me know if you have any questions.
Well, rebind the whole datasource is not a so good solution I think... but I don't have any other !
The problem is that when doing this, you lose the information whether the node is expanded or not.
To solve the issue my solution is to browse every record and add the dataitem of the expanded ones to a HashSet before rebinding the datasource to the grid.
After rebinding the datasource, I find the record associated to those dataitems and expand them.
What doesn't satisfy me is that it can take some time from hudge datasource...
In VB.NET it looks like :
Dim hs As New HashSet(Of Object) For Each node In Me._xamDataGrid.Records If node.IsExpanded And node.IsDataRecord Then Dim dr = DirectCast(node, DataRecord) hs.Add(dr.DataItem) End If Next Me._xamDataGrid.DataSource = Nothing Me._xamDataGrid.DataSource = Me._viewSource.View For Each dataItem In hs Dim record = Me._xamDataGrid.GetRecordFromDataItem(dataItem, True) If record IsNot Nothing Then record.IsExpanded = True End If Next