Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] [UWP, iOS] Can't set transparent color on selected template item in CollectionView #11421

Closed
themronion opened this issue Jul 13, 2020 · 7 comments · Fixed by #12651
Closed
Assignees
Labels
a/collectionview e/5 🕔 5 in-progress This issue has an associated pull request that may resolve it! p/iOS 🍎 t/bug 🐛
Milestone

Comments

@themronion
Copy link

themronion commented Jul 13, 2020

Description

Can't set transparent color on selected template item in CollectionView on iOS. Other colors work. As i found the issue with "selected" state in UWP is being resolved so maybe this is only an iOS issue

Steps to Reproduce

  1. Try the code from official sample docs: click
  2. Set background color to Transparent
  3. See that the color is not being changed to transparent on iOS (uwp).

Expected Behavior

Color is being set to Transparent on all platforms

Actual Behavior

Color is not being set to Transparent on iOs (uwp)

Workaround

Set background color as property of binded observablecollection item

@jsuarezruiz
Copy link
Contributor

@themronion Do you mean modify the background color using the Selected VisualState?

@jsuarezruiz jsuarezruiz added the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Jul 14, 2020
@themronion
Copy link
Author

@jsuarezruiz yeap

@themronion
Copy link
Author

Any progress here?

@samhouts samhouts removed the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Jul 16, 2020
@jsuarezruiz
Copy link
Contributor

I have done some tests on Android, iOS and UWP. The behavior seems the same on all platforms:

  • If a background color is set using the Selected state, the selection color is modified.
  • If the Selected state is not used, by default, a selection color is applied.
  • If a transparent color is applied in the Selected state, the behavior is the same as in the previous point.

Android

Using:

<VisualState x:Name="Selected">
     <VisualState.Setters>
          <Setter Property="BackgroundColor" 
               Value="Transparent" />
     </VisualState.Setters>
</VisualState>

Captura de pantalla 2020-07-17 a las 12 53 15

Using transparent:

Captura de pantalla 2020-07-17 a las 12 53 27

UWP
Captura de pantalla 2020-07-17 a las 12 57 22
Captura de pantalla 2020-07-17 a las 12 54 07

The expected behavior would be not to apply any selected color (avoid the native selection color)?

@jsuarezruiz jsuarezruiz added the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Jul 17, 2020
@themronion
Copy link
Author

themronion commented Jul 19, 2020

Yes, on android i managed somehow to avoid the selection color in a selected collection view item. As i now realized this wasn't because i was setting a transparent color in the vsm. But how then to acheive not a gray background (on ios) on a selected collection view item, but a transparent one? Using custom renderers i did the trick with a listview, but how to write a renderer to remove the selection color in a collection view in ios a have no idea. I thought i would acheive that with VSM, but no... maybe you can give me a tip?

@samhouts samhouts removed the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Jul 21, 2020
@hartez hartez removed the s/unverified New report that has yet to be verified label Jul 24, 2020
@hartez hartez self-assigned this Jul 24, 2020
@hartez hartez added the e/5 🕔 5 label Jul 24, 2020
@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Jul 30, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
rmarinho pushed a commit that referenced this issue Nov 1, 2020
#12651) fixes #7790 fixes #9590 fixes #11421

* Correction of CollectionView to work properly with selected item color when using VisualState on Android and iOS

* Update TemplatedCell.cs

* Update TemplatedItemViewHolder.cs

* Add scaling to make the bug more obvious

* Make fix work for on-template visual states on iOS

* Make fix for for on-template visual states on Android

* Minor performance optimization

* Make method name more explicit

* Spaces -> Tabs

* Fix UI test failure (item 3 doesn't fit on the screen anymore)

Co-authored-by: Rony Mesquita <ronymesquitadasilva@gmail.com>
@jthun
Copy link

jthun commented Aug 27, 2021

Hi,

This still seems to be an issue in XF 5.0.0.2083.

This code makes the selected frame transparent on Android, but an ugly gray on iOS. Are there other ways to achieve a transparent background on the selected item in a CollectionView for iOS?

<VisualStateManager.VisualStateGroups>
    <VisualStateGroup Name="CommonStates">
        <VisualState Name="Normal">
            <VisualState.Setters>
                <Setter Property="BackgroundColor" Value="Transparent" />
            </VisualState.Setters>
        </VisualState>
        <VisualState Name="Selected">
            <VisualState.Setters>
                <Setter Property="BackgroundColor" Value="Transparent" />
            </VisualState.Setters>
        </VisualState>
    </VisualStateGroup>
</VisualStateManager.VisualStateGroups>`

@jthun
Copy link

jthun commented Sep 14, 2021

@samhouts, @hartez, can you please provide on update? Is this being worked on?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.