Anyone else seeing something similar?
VS2019 windows - Xamarin Forms App - Runs fine on Android
Same app when run to iOS breaks on the ListView
and CollectionView
If I take out all three, it runs fine.
If I take out the CollectionView
only - it breaks
If I take out both of the ListView
- it breaks
Sure seems like the common class they derive from (ItemView
) has a problem on iOS only.
Thoughts? - Again, runs fine in Android
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="RpxSkeleton.MainPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:RpxSkeleton"
x:Name="this"
BackgroundColor="{Binding App.CurrentTheme.WindowBackground}"
ControlTemplate="{StaticResource PageTemplateDefault}">
<ScrollView Orientation="Vertical" VerticalScrollBarVisibility="Always">
<StackLayout Orientation="Vertical">
<Label
BackgroundColor="{Binding App.CurrentTheme.LabelBackground}"
FontSize="20"
HorizontalOptions="Center"
Text="RedPillXamarin.com™"
TextColor="{Binding App.CurrentTheme.LabelForegound}"
VerticalOptions="Center" />
<Grid>
<StackLayout>
<Button
x:Name="Test"
Clicked="Test_OnClicked"
Text="Test" />
</StackLayout>
</Grid>
<Button Command="{Binding ToggleIsBusyCommand}" Text="Toggle IsBusy" />
<ListView
BackgroundColor="Blue"
IsEnabled="True"
ItemsSource="{Binding WidgetCollection}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal">
<Switch IsToggled="{Binding IsSelected}" />
<Entry BackgroundColor="Lime" Text="{Binding Name}" />
<DatePicker BackgroundColor="SaddleBrown" Date="{Binding SomeDate}" />
<!-- UI layer even for UI purposes. Not for logic or workflow -->
<!-- Notice that it is automatically wired to the page code behind without having to specify it -->
<Button Clicked="Button_OnClicked" Text="UI Layer" />
<!-- The ListView binded collection element has the command and the handler -->
<Button Command="{Binding ModelCommand}" Text="Model Command" />
<!-- The command is on the ViewModel and takes the collection element as the parameter -->
<Button
Command="{Binding Source={x:Reference this}, Path=BindingContext.VmCommand}"
CommandParameter="{Binding .}"
Text="VM Command" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.Triggers>
<DataTrigger
Binding="{Binding IsBusy}"
TargetType="{x:Type ListView}"
Value="True">
<Setter Property="IsEnabled" Value="False" />
<Setter Property="BackgroundColor" Value="{StaticResource ColorYellow}" />
</DataTrigger>
</ListView.Triggers>
</ListView>
<CollectionView ItemsSource="{Binding WidgetCollection}">
<!--#region View when no data-->
<CollectionView.EmptyView>
<Label Text="No items to display" />
</CollectionView.EmptyView>
<!--#endregion View when no data-->
<!--#region View when yes data-->
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Entry BackgroundColor="Lime" Text="{Binding Name}" />
<DatePicker BackgroundColor="SaddleBrown" Date="{Binding SomeDate}" />
<Button
Grid.Row="1"
Grid.Column="0"
Clicked="Button_OnClicked"
Text="UI Layer" />
<Button
Grid.Row="1"
Grid.Column="1"
Command="{Binding ModelCommand}"
Text="Model Command" />
<Button
Grid.Row="1"
Grid.Column="2"
Command="{Binding Source={x:Reference this}, Path=BindingContext.VmCommand}"
CommandParameter="{Binding .}"
Text="VM Command" />
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
<!--#endregion View when yes data-->
</CollectionView>
<ListView ItemsSource="{Binding WidgetCollection}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout BackgroundColor="{StaticResource ColorGreen}" Orientation="Horizontal">
<StackLayout.Triggers>
<DataTrigger
Binding="{Binding IsSelected}"
TargetType="StackLayout"
Value="true">
<Setter Property="BackgroundColor" Value="{StaticResource ColorRed}" />
</DataTrigger>
</StackLayout.Triggers>
<Label
BackgroundColor="{StaticResource ColorBlack}"
FontSize="{StaticResource FontSizeRegular}"
Text="{Binding Name}"
TextColor="{StaticResource ColorWhite}" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button Command="{Binding ResetCommand}" Text="Reset All" />
</StackLayout>
</ScrollView>
</ContentPage>