BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
My first try was to just bind SpanCount with a ViewModel Property and change it when the OnPortraitMode() and OnLandcapeMode() methods get called:
<syncfusion:SfListView ItemsSource="{Binding Path=ItemList}" ItemSize="280" ItemSpacing="10,10,0,0" VerticalOptions="FillAndExpand">
<syncfusion:SfListView.LayoutManager>
<syncfusion:GridLayout SpanCount="{Binding Path=SpanCount}" />
</syncfusion:SfListView.LayoutManager>
This isn't working, I think SpanCount isn't able to be bound.
Second try was to use triggers and bind to the IsLandscape-Property:
<syncfusion:SfListView ItemsSource="{Binding Path=ItemList}" ItemSize="280" ItemSpacing="10" VerticalOptions="FillAndExpand">
<syncfusion:SfListView.Resources>
<ResourceDictionary>
<syncfusion:GridLayout x:Key="LandscapeGridLayout" SpanCount="4"></syncfusion:GridLayout>
<syncfusion:GridLayout x:Key="PortraitGridLayout" SpanCount="2"></syncfusion:GridLayout>
</ResourceDictionary>
</syncfusion:SfListView.Resources>
<syncfusion:SfListView.Triggers>
<DataTrigger TargetType="syncfusion:SfListView" Binding="{Binding Path=IsLandscapeMode}" Value="True">
<Setter Property="syncfusion:SfListView.LayoutManager" Value="{StaticResource LandscapeGridLayout}"></Setter>
</DataTrigger>
<DataTrigger TargetType="syncfusion:SfListView" Binding="{Binding Path=IsLandscapeMode}" Value="False">
<Setter Property="syncfusion:SfListView.LayoutManager" Value="{StaticResource PortraitGridLayout}"></Setter>
</DataTrigger>
</syncfusion:SfListView.Triggers>
<syncfusion:SfListView.ItemTemplate>...
This is working but only for one mode-change: e.g. Portrait -> Landscape, changing back causes an unhandled NullReferenceException.
I attached a sample-project for reproducing this behavior and the exception. I'm using the last Syncfusion version 15.1.0.41 (with nuget packages) and test currently only for Android and UWP (but the ListView is initialized in iOS too).
I hope anyone cal help getting the wanted behavior by using MVVM.
Thanks
Christopher
XAML:
<syncfusion:SfListView x:Name="listView" BindingContextChanged="ListView_BindingContextChanged" ItemsSource="{Binding Path=ItemList}">
...
</syncfusion:SfListView>
C#:
private void ListView_BindingContextChanged(object sender, System.EventArgs e)
{
this.listView.LayoutManager.BindingContext = this.listView.BindingContext;
} |
Hi,
We have the same issue for the same usecase.Looks like this might have broken. We are using 18.2.0.47.
Raghav