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 / Highlighting Selected ...
Power Apps
Answered

Highlighting Selected Button Only

(0) ShareShare
ReportReport
Posted on by

I have a client who has built an app in Excel. Not good so I have been tasked with replicating it in PowerApps. The UI is very unique but the client is determined for me to keep the "Excel" UI the same if at all possible. I have replicated the table with buttons in PowerApps and am pulling the values perfectly. Everything is working correctly except one UI feature they really would like replicated. They would like the current active "Selected" button to be red. Here is what their current grid looks like:

GregGuth_BP_0-1611356490367.png

I have replicated the look in PowerApps and it looks like this:

GregGuth_BP_1-1611356615168.png

The OnSelect code for each button looks like this:

Set(varContainerSize,"96G");
Set(varServiceFrequency,"1");

UpdateContext({pressedButton:!pressedButton});

I set the 2 variables per the values on each button. I then add in "UpdateContext" code to switch the color of the button.

 

The Fill code for each button looks like this:

If(pressedButton=true, Color.Red, RGBA(62,96,170,1))

 

This starts off each button as blue and when it is selected it turns red just as the client wants.

 

Here is my challenge. I need to reset all buttons to blue first then set the color of the last clicked button to red so that only the current button is red. I have tried all kinds of things such as grouping the buttons and setting them all to blue and after that set the code above but my end result is all buttons cycle from red to blue. All buttons act as one.

 

Any suggestions?

 

Categories:
I have the same question (0)
  • Verified answer
    Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    I think you can do this with an update to the OnSelect and Fill properties of the buttons. 

     

    Add this Set() to the OnSelect, so it will create and update a variable that will track the last button pressed. 

    OnSelect > Set(varButtonPressed, Self.Text)

     

    Then update the Fill property to set the color to Red if variable equals the button text otherwise set the color to Blue.

    Fill > If(Self.Text = varButtonPressed, Red, Blue)

     

     

     

     

  • Community Power Platform Member Profile Picture
    on at

    Jeff, This worked. My OnSelect looks like this:

    Set(varContainerSize,LookUp('[quote].[ContainerSize]',Display="64 G"));
    Set(varServiceFrequency,LookUp('[quote].[ServiceFrequency]',Display="EOW"));
    UpdateContext({pressedButton:!pressedButton});

     

    My Fill looks like:

    If(varServiceFrequency.Display="EOW" && varContainerSize.Display="64 G", RGBA(200,00,00,1), RGBA(62,96,170,1))

     

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard