xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.64k stars 1.88k forks source link

[Bug] CollectionView - Binding for SelectedItem not working on iOS #13141

Open WanftMoon opened 3 years ago

WanftMoon commented 3 years ago

Description

When you bind the property CollectionView.SelectedItem and set a value to it on the code behind, it does not select the item on iOS.

Steps to Reproduce

  1. Create a collectionview with selectionmode single and binded selecteditem and itemssource;
    CollectionView ItemsSource="{Binding Installments, Source={Reference _this}}"
                          SelectedItem="{Binding SelectedInstallment, Source={Reference _this}, Mode=TwoWay}"
                          SelectionMode="Single"/>
  2. run on ios and android, only working on the later
Screen Shot 2020-12-14 at 13 59 52

Expected Behavior

same behavior on both platforms

Actual Behavior

only android works, iOS fails

Basic Information

Environment

Show/Hide Visual Studio info ``` === Visual Studio Community 2019 for Mac === Version 8.8.3 (build 16) Installation UUID: 8da76b74-f045-4d85-b49d-5c7d5d09c5bb GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638) Package version: 612000107 === Mono Framework MDK === Runtime: Mono 6.12.0.107 (2020-02/a22ed3f094e) (64-bit) Package version: 612000107 === Roslyn (Language Service) === 3.8.0-5.20519.18+4c195c3ac1974edcefa76774d7a59a2350ec55fa === NuGet === Version: 5.8.0.6860 === .NET Core SDK === SDK: /usr/local/share/dotnet/sdk/5.0.100/Sdks SDK Versions: 5.0.100 3.1.404 3.1.403 3.1.402 3.1.401 3.1.302 3.1.301 3.1.300 3.1.202 3.1.200 MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks === .NET Core Runtime === Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 5.0.0 3.1.10 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.2 2.1.23 2.1.22 2.1.21 2.1.20 2.1.19 2.1.18 2.1.17 === .NET Core 3.1 SDK === SDK: 3.1.404 === Xamarin.Profiler === Version: 1.6.13.11 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler === Updater === Version: 11 === Xamarin.Android === Version: 11.1.0.17 (Visual Studio Community) Commit: xamarin-android/d16-8/c0e2b8e Android SDK: /Users/moonlighters/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: None installed SDK Tools Version: 26.1.1 SDK Platform Tools Version: 30.0.5 SDK Build Tools Version: 29.0.2 Build Information: Mono: be2226b Java.Interop: xamarin/java.interop/d16-8@79d9533 ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000 SQLite: xamarin/sqlite/3.32.1@1a3276b Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-8@2fb1cbc === Microsoft OpenJDK for Mobile === Java SDK: /Users/moonlighters/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25 1.8.0-25 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL === Android SDK Manager === Version: 16.8.0.32 Hash: 01a7774 Branch: remotes/origin/d16-8 Build date: 2020-10-13 23:32:30 UTC === Android Device Manager === Version: 16.8.0.45 Hash: fc0af5f Branch: remotes/origin/d16-8 Build date: 2020-10-13 23:32:54 UTC === Apple Developer Tools === Xcode 12.2 (17535) Build 12B45b === Xamarin.Mac === Version: 7.0.0.15 (Visual Studio Community) Hash: 87a1b18d8 Branch: d16-8 Build date: 2020-11-16 21:39:40-0500 === Xamarin.iOS === Version: 14.6.0.15 (Visual Studio Community) Hash: 87a1b18d8 Branch: d16-8 Build date: 2020-11-16 21:39:41-0500 === Xamarin Designer === Version: 16.8.0.507 Hash: e87b24884 Branch: remotes/origin/d16-8 Build date: 2020-10-29 00:31:38 UTC === Build Information === Release ID: 808030016 Git revision: cc6375d2fdcc1b42532e551e24ce650eaca1ae45 Build date: 2020-11-25 13:16:20-05 Build branch: release-8.8 Xamarin extensions: cc6375d2fdcc1b42532e551e24ce650eaca1ae45 === Operating System === Mac OS X 10.16.0 Darwin 20.1.0 Darwin Kernel Version 20.1.0 Sat Oct 31 00:07:11 PDT 2020 root:xnu-7195.50.7~2/RELEASE_X86_64 x86_64 === Enabled user installed extensions === Xamarin.Forms HotReload extension 1.4.0 Android Signature Tool 2.2.0 ```

Build Logs

N/A

Screenshots

Screen Shot 2020-12-14 at 13 59 52

Reproduction Link

CVSelItem.zip

Workaround

N/A

rachelkang commented 3 years ago

Hi, @WanftMoon - thanks for submitting this issue. We'll be sure to explore this further. In the meantime, this seems related to https://github.com/xamarin/Xamarin.Forms/issues/9511 so you may find some of the conversations on that thread helpful