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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Change Gallery Button ...
Power Apps
Answered

Change Gallery Button if selected

(0) ShareShare
ReportReport
Posted on by 392

I just do not understand.

I use a gallery with a button as an art menu to display more content on this page.

Now that I have selected a button, that button should be given a different fill color to show the user what choice he has made.

Thank you for your help

 

Unbenannt.PNG

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,923 on at

    At the OnSelect of the Button:
    Collect(ColorButton, ThisItem.ID)


    Then on the Fill of the button:
    If(ThisItem.ID in ColorButton, Yellow,Blue)

    If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution

  • v-yutliu-msft Profile Picture
    on at

    Hi @Robertjde ,

    Do you want to change button's color when it is selected?
    I've made a similar test for your reference:
    I insert 5 buttons as an example. When you click the button, the button's color will change to red, or else it will be blue.

    1)set button1's OnSelect:

    Set(var,"button1")

    set button1's Fill:

    If(var="button1",Red,Blue)

     2)set button2's OnSelect:

    Set(var,"button2")

     

     

    set button2's Fill:

     

    If(var="button2",Red,Blue)

     

    3)set button3's OnSelect:

     

    Set(var,"button3")

     

    set button3's Fill:

     

    If(var="button3",Red,Blue)

     

    4)set button4's OnSelect:

     

    Set(var,"button4")

     

    set button4's Fill:

     

    If(var="button4",Red,Blue)

     

    5)set button5's OnSelect:

     

    Set(var,"button5")

     

    set button5's Fill:

     

    If(var="button5",Red,Blue)

     

     

    Then the variable's value will change based on which button you click. The button's fill will change based on the variable value.

    32022.PNG

     

    Best regards,

  • Robertjde Profile Picture
    392 on at

    @eka24 

    the buttons remain in the color selection, as in the example yellow, but should turn blue again when I select the 2nd button

  • Robertjde Profile Picture
    392 on at

    @v-yutliu-msft 

    The buttons are integrated in a gallery, which is why the Onselect button 1,2,3,4,5 does not work and if I only use the IF function with button 1, all buttons are color-matched and not just the selected one.

  • eka24 Profile Picture
    20,923 on at

    The ID should be preferably a unique field in the Table or collection. So change the ID to one of the columns.

    Collect(ColorButton, ThisItem.ID)
    If your doesnt work show your formula for correction. its straight forward
     
    Capture.JPG
  • Robertjde Profile Picture
    392 on at

    @eka24 the colors do not change back when i choose another button

     

    Fill.PNG

    onselect.PNG

    Gallery viewGallery view

  • eka24 Profile Picture
    20,923 on at

    I think everything if fine except the Result column in the table may not be unique. Can you change the Result to Another Column

  • Robertjde Profile Picture
    392 on at

    @eka24 ONLY the selected button should appear in a different color, because I change the content of my table (see arrow) via this button and the user should recognize which button he clicked

     

    gallerie.PNG

  • eka24 Profile Picture
    20,923 on at

    Please what are the columns names in your table? Do you only have "Result" as your column name. Example do you have Name, ID or Any other column. i suggest you change the result with another ColumnName

  • Robertjde Profile Picture
    392 on at

    @eka24 I have in the Item Gallery Sort (Distinct (.. Function and the button ID only "Result"

     

    gallerie.PNG

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard