I'm having trouble applying both FitColumnWidthToContent and CellTextAlignment.
Re: FitColumnWidthToContent , I'm using a custom data provider. It obtains its data through a 2-step process. First, to help clean up memory (the grid is being used essentially as a pivot table and so it gets heavy use), the existing collection is cleared and the associated custom data property is nullified prior to each load:
CustomDataProvider = null;
Then the data is reloaded via CustomData = PivotsDB.RetrieveData();
Both CustomData and CustomDataProvider are properties that call RaisePropertyChanged() as per your ViewModelBase helper class.
As a consequence of this setup, the Loaded event for my RadVirtualGrid only fires once, i.e. the fist time the grid is loaded.
To implement your suggested code re: FitcolumnWidthToContent, I therefore created a private method:
private void DataChanged(object sender, PropertyChangedEventArgs e)
for (int i = 0; i < RadVirtualGrid1.InitialColumnCount; i++)
...and registered this method in the code-behind file:
var mvm = Application.Current.MainWindow.DataContext as MainWindowViewModel;
PivotsViewModel vm = mvm.CurrentPageViewModel as PivotsViewModel;
vm.PropertyChanged += DataChanged;
I have confirmed that my DataChanged method is firing, but it has no effect on the column sizes. And, yes, I have set my MeasureTextOnRender="True".
The problem with CellTextAlignment is much more straightforward. I'm using your recommended code as follows:
private void RadVirtualGrid1_CellDecorationsNeeded(object sender, Telerik.Windows.Controls.VirtualGrid.CellDecorationEventArgs e)
e.CellTextAlignment = TextAlignment.Right;
...but CellTextAlignment is not a member of CellDecorationEventArgs, and if it is an extension method, VS isn't helping me find it.