I can successfully provide an initial sort order for my VirtualGrid using this code in the code behind file, as prescribed by your documentation:
var sortDescriptor = this.VirtualGrid.GetSortDescriptorForColumn(0);
sortDescriptor.SortDirection = System.ComponentModel.ListSortDirection.Ascending;
sortDescriptor.IsActive = true;
However, for reasons beyond the scope of this issue, my source data (an observable collection) and my custom data provider are created in my view model. My custom data provider is bound to the VirtualGrid via XAML.
Therefore, any attempt to apply your sorting code in the constructor of the code behind file fails because both the DataContext and DataProvider properties are not yet assigned in that instant (they are null), i.e. they are not populated until the View Model constructor files.
I can achieve what I want by placing the aforementioned code in the VirtualGrid's Loaded event in the code-behind file, but as a Newbie, I am concerned whether this is the correct solution.