I need my View to have all the nodes expanded when the user navigates to it.
To achieve this, I have added the Loaded event of the gird, and perform a xamGrid.Records.ExpandAll(true). The timing is not correct though. At the time the Loaded event fires off, there are no records in the xamGrid, so there is nothing to expand. When I add a bit of a delay on the getter of my ObservableCollection (set as the datasource of the grid), the Records are present, and they correctly expand. This approach does not guarantee the success of the nodes expanding in all cases though (since the added delay is somewhat trivial).
I have also tried adding an event to the DataRecordPresenter(or something similar?) to expand the nodes. As with previous attempts on styling/working with the DataRecordPresenter, the rendering is inconsistent since there is a lag. Do you have any suggestions to achieve what I need? Please! :) Thanks.
Hello dbeavon,
While I am not extremely well versed in design-time debugging and coding, I believe that I have found a way that you may be able to get your XamDataGrid records to expand in the Visual Studio designer. I have been debugging the XamDataGrid at design time, but I haven't been able to find a spot where the Records collection is populated and available for the ExpandAll(true) method to be called.
I did get this to work by involving the creation of a derived XamDataGrid. In the constructor of this derived XamDataGrid, you can call the following code to get the child records to expand at design time:
if (DesignerProperties.GetIsInDesignMode(this)) { Dispatcher.BeginInvoke(new Action(() => { Records.ExpandAll(true); })); }
It appears that at this point, the Records collection is populated, and the parent records expand in the designer with this method. I have attached a sample project to demonstrate the above. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Any word on a better way to modify xamDataGrids with nested levels of data? The designer doesn't want to expand nodes by default so usually I resort to launching test apps over and over and over again.
It has been a year and I'd love to find a more productive approach for working on my xamDataGrid designs.
Hello,
Thank you for your post. I have been looking into your requirement and it seems like that the approach you use is the best one. If I think of a better one I will let you know.
Sorry to reply to an old post. Is there a way to get expansion to work in the VS designer?
The solution you gave doesn't run the trigger in the designer for the UserControl where the xamDataGrid is used. The only way I could get the expansion to work is to create another UserControl as a type of designer harness that just includes the other UserControl (the one with the xamDataGrid).
Please let me know if there is an easier way. In the case of hierarchical data with complex sample data, it would be nice to see it all without jumping thru hoops.
I'm fairly new to WPF.
Hello Daniel,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.