I started using ComponentOne's C1FlexGrid for my WPF Caliburn.Micro application. I wonder how I can set with of the columns to the maximum contents width. I tried to make it Auto, but the width is still the same for all columns.
I applied AutoSizeColumns like this:
protected override void OnViewAttached(object view, object context)
{
var View = (FirstDataEntryView)view;
View.EnrollmentFiles.AutoSizeColumns(0, 4, 5);
}
but this didn't help...
Thanks
Using GridLength.Auto usually doesn't work for these column widths because of virtualization. FlexGrid has a couple methods to autosize the columns but the columns must be visible or they won't be calculated and will remain the static width. Here is a very non-production-worthy example of how to do this. FWIW this is why I never liked ComponentOne controls -- it felt like they were stuck in WinForms mode.
edit: Adding some code for CM-specific usages.
As far as whether or not accessing the view from a viewmodel is "compliant" with MVVM theories -- technically it is not, but sometimes you are forced to use controls that just cannot be automatically configured through XAML, and you can't use the View's code-behind because of one reason or another.