Hi,
I have the following Grid Columns:
<sfDataGrid:SfDataGrid.Columns>
<sfDataGrid:GridTextColumn MappingName="Nr" HeaderText="Nr" ColumnSizer="Auto" />
<sfDataGrid:GridTextColumn MappingName="KeyNr" HeaderText="KeyNr." ColumnSizer="Auto"
IsHidden="{Binding Path=BindingContext.ShowAlternateKey, Source={x:Reference Name=MyPageName},Converter={StaticResource InverseBoolConverter}}"/>
<sfDataGrid:GridTextColumn MappingName="KeyNrAlternate" HeaderText="KeyNr" ColumnSizer="Auto"
IsHidden="{Binding Path=BindingContext.ShowAlternateKey, Source={x:Reference Name=MyPageName}}"/>
<sfDataGrid:GridTextColumn MappingName="Description" HeaderText="Description" ColumnSizer="LastColumnFill" />
<sfDataGrid:GridTextColumn MappingName="NotAlternateCol" HeaderText="" ColumnSizer="Auto" MinimumWidth="50"
IsHidden="{Binding Path=BindingContext.ShowAlternateKey, Source={x:Reference Name=MyPageName},Converter={StaticResource InverseBoolConverter}}" />
<sfDataGrid:GridNumericColumn AllowEditing="False" MappingName="Count" HeaderText="Count"
ColumnSizer="Auto" NumberDecimalDigits="0" MinimumWidth="100"
LoadUIView="True" />
<sfDataGrid:GridNumericColumn MappingName="WeightSum" NumberDecimalDigits="3" HeaderText="Weight" ColumnSizer="Auto"
MinimumWidth="100" />
</sfDataGrid:SfDataGrid.Columns>
The Grid should expand the whole page width. HorizontalOptions="FillAndExpand" is set on the Grid itself. The Description Column should expand empty space.
Showing and hinding the columns is working fine.
The problem ist that the hidden columns are taking their width so the grid isn't expanding over the full page width.
I'm also hiding data by the IsSelected property of the object by calling a view filter after view is created.
I tried to call "this.MyDataGrid.GridColumnSizer.Refresh(true);" after the filter has been triggered but that doesn't work.
Do I miss something? Shouldn't be the width of a hidden column at 0 by default?
I don't need to change the ShowAlternateKey property at runtime, it is only set once on the page lifetime. I guess a possible solution would be to move the column definition to code behind. But I'm using heavily MVVM, so the property is living in the ViewModel only and I want to avoid code behind as much as possible.
Maybe anyone can help.
Greetings
Christopher