web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / undo color change when...
Power Apps
Answered

undo color change when item is not selected anymore

(0) ShareShare
ReportReport
Posted on by 11

Hello all,

I'm refreshing some of mine (little 😉 )knowledge in Powerapps. I found out how to color a selected item in a gallery via 'template fill'.
If (ThisItem.IsSelected;Green;GhostWhite)

 

Know I also want that when I unselect an item by clicking on the selected item that the color changes again to 'GhostWhite'. 
Can anybody help me with that.?
Do I need to work with the OnSelect or with the 'TemplateFill'?

Big tnx
Siegfried



Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Siegfried_VH 

    You cannot have an unselected row in a Gallery...there is always something selected.  So, if you are basing off of IsSelected, you will have something with the Green color always.

     

    If you are trying to create the illusion of something selected or not, then you will need to resort to a snapshot variable to get the illusion you want.

     

    Ex. on the OnSelect of your Gallery, the following:  UpdateContext({lclSelected: If(ThisItem.ID = lclSelected; 0; ThisItem.ID)})

     

    Then in your TemplateFill:

      If(ThisItem.ID = lclSelected; Green; GhostWhite)

     

    I hope this is helpful for you.

  • Siegfried_VH Profile Picture
    11 on at

    Tnx, did'nt know that in a Gallery there is always something selected.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Siegfried_VH 

    Yep...always something!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard