I have noticed something odd with the latest version of Xamarin.Forms (5.0.02244) and building for iOS 15. The below does not affect the Android version of this application, building with the latest XF against Android works fine with this code. This problem was not here with XF < v5 or iOS 14.
Has something changed with the IsVisible logic between Xamarin.Forms v4.x and v5? Again, the same code works fine downgrading to XF 4. But with the latest XCode version and iOS 15 I need to now use XF v5.
Or have I been doing this wrong and it just happened to work with XF v4 (and still works on Android with XF v5)
Minimal example:
Below is the XAML for a search box and results view. The results view populates with Items that contain the text being typed in the search box (ItemsList). The height of this is also set by searchZoneHeight. This all works fine on Android and iOS XF < v5.
isSearchResultVisible is set when the user taps an item, tapping the item sets the search bar text to be that item and then hides the search results.
What I am seeing in iOS with XF v5 is that the CollectionView remains visible as a white box. The size of the white box is the height of one search result. So the height of the view is correctly set but the request for isSearchResultVisible = false; isn't being respected. There are no error outputs in the console.
If I bind the request to make something invisible to another UI component on tap it works. Seems only the RefreshView/CollectionView are ignoring it.
Any suggestions are much appreciated thanks,
XAML
<SearchBar Text="{Binding searchText}" Placeholder="Type to search" IsSpellCheckEnabled="False" />
<RefreshView x:DataType="local:ViewModel" IsVisible="{Binding isSearchResultVisible, Mode=TwoWay}" Command="{Binding searchItems}" >
<CollectionView HeightRequest="{Binding searchZoneHeight}" x:Name="ItemsList"
ItemsSource="{Binding searchResultItems}"
SelectionMode="None" >
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout Padding="10" x:DataType="model:Item" >
<Label Text="{Binding Text}"
Style="{DynamicResource ListItemTextStyle}"
FontSize="16" />
<StackLayout.GestureRecognizers>
<TapGestureRecognizer
NumberOfTapsRequired="1"
Command="{Binding Source={RelativeSource AncestorType={x:Type local:ViewModel}}, Path=ItemTapped}"
CommandParameter="{Binding .}">
</TapGestureRecognizer>
</StackLayout.GestureRecognizers>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</RefreshView>
View Model
async void OnItemSelected(Item item)
{
// This fires so I know the tap event works
Debug.WriteLine("Search result was tapped " + item.Text);
// Below line does set the search text correctly (iOS and Android)
searchText = item.Text;
// Below doesn't work on iOS
isSearchResultVisible = false;
OnPropertyChanged(nameof(isSearchResultVisible));
// Below line also does not work on iOS
//OnPropertyChanged("isSearchResultVisible");
}