Hello,
we inherited our control from XamDataGrid to extend it by some other methods. In particular, we need to be able to programmatically hide certain columns after loading the user-defined column layout. It looks like this (usually not async, it's for testing purposes):
public async void ApplyCustomLayout(string layout){ this.LoadCustomizations(layout); foreach (var field in this.FieldLayouts[0].Fields) { if (someListOfColumnNamesToExlude.Contains(field.Name)) { field.Visibility = Visibility.Collapsed; field.Settings.AllowHiding = AllowFieldHiding.Never; } } var hidden = this.FieldLayouts[0].Fields.Where(f => f.Visibility == Visibility.Collapsed).ToArray(); await Task.Delay(20000); var hiddenLater = this.FieldLayouts[0].Fields.Where(f => f.Visibility == Visibility.Collapsed).ToArray();}
In the user-saved XML layout file, the visibility of some of these columns we want to hide is "Visible". Now right after the loop, all the columns in the list are correctly set to "Collapsed" and therefore contained by the test variable "hidden". But 20 seconds later, they are set to "Visible" again (thus not contained in "hiddenLater"), which apparently comes from the XML file we load. So I guess there is some kind of asynchronous process going on with "LoadCustomizations" that doesn't transfer the XML layout instantly. Manually removing Visibility="Visible" inside the XML file leads to the correct behaviour, but unfortunately is not a real option for us since we cannot influence the actual XML files with our client.
My question: Is there any other way to do this "hiding loop" AFTER the XML layout has been fully loaded, so our changes to the visibility are not overwritten? For instance, an event that definitely fires AFTER this is through and that we could (ab)use for this purpose? Perhaps our whole idea of just looping through the fields is flawed...
Thanks in advance
Johannes
Hello Johannes,
I have been looking into your issue and this approach should work and there shouldn’t be a 20 second delay like the one you describe, so I was wondering, if there is anything more to your project and/or extensions you have made that might be causing this.
In regards to your question there is no even to notify when loading the customization is complete. You can suggest new Product Ideas for future versions (or vote for existing ones) at http://ideas.infragistics.com.
Steps to create your idea:
Log into the Infragistics Product Ideas site at http://ideas.infragistics.com (creating a new login if needed).
Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)
Add your product idea and be sure to be specific and provide as much detail as possible. Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing!
The benefits of submitting the product idea yourself include:
Direct communication with our product management team regarding your product idea.
Notifications whenever new information regarding your idea becomes available.
Additional benefits of the Product Idea system include:
Ability to vote on your favorite product ideas to let us know which ones are the most important to you. You will have ten votes for this and can change which ideas you are voting for at any time.
Allow you to shape the future of our products by requesting new controls and products altogether.
You and other developers can discuss existing product ideas with members of our Product Management team.
The product ideas site allows you to track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.
Sincerely,
Petar.