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 / How to turn a button v...
Power Apps
Answered

How to turn a button visible=false or disabled=true?

(2) ShareShare
ReportReport
Posted on by 81

I tried to make a button visible=true or disabled=false with the click of another button, but it does not work. Anybody with the same problem?

Categories:
I have the same question (0)
  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    You can use context variables to do that. Here's one possible implementation for your scenario (using this screen below):

     Buttons.PNG

    We would set the OnSelect property for the "action" buttons to update a context variable:

    EnableButton.OnSelect: UpdateContext({ enabled: true })
    DisableButton.OnSelect: UpdateContext({ enabled: false })
    HideButton.OnSelect: UpdateContext({ visible: false })
    ShowButton.OnSelect: UpdateContext({ visible: true })

    And in the button that you want to show / hide / disable / enable, you would bind the Disabled and Visible properties to those context variables:

    MyButton.Disabled: !enabled
    MyButton.Visible: visible
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @CarlosFigueira Thank you for the solution.

    Also, thanks to your reply, now I understand what a Variable is.

    So double thanks.

    Smiley Happy

  • audrieFCT Profile Picture
    987 on at

    I have a follow-up question on this. The problem I have is two-fold:

     

    1. The visible property not only hides the button during run time, but also in design. (which means to get the button back I either need to use the advanced property pane, or find a way to make it visible again in run time).

    2. I wish I had a "on focus" for the screen, so that when the app starts it resets everything to visible. I tried with OnVisible but the button is staying hidden....

     

    Do you have a way to do #2?

  • Brian Dang Profile Picture
    3,976 on at

    When you write a formula in the OnVisible property of a Screen, you need to navigate away and return for it to take effect. 

     

    That said, here are some tips:

    • All context variables are false by default at the start of the app. Rather than defining your variables in the positive sense, you can define them in the negative sense. So rather than "enable" and "visible" properties, you can call it "disable" and "hidden."
    • Or: If you went with the solution by @CarlosFigueira, then you can add the following formulas in the OnVisible property of your desired Screen:
      UpdateContext({
      enabled: true,
      visible: true
      })
    • OnVisible only triggers once. A more exact name for the property would be "OnNavigationToThisScreen." If you want something to continually force the button to stay a certain way, then you can bind the button itself using App.ActiveScreen. App.ActiveScreen=NameOfScreen checks to see if the screen you're looking at is the active one.

      Button1.Disabled: !(App.ActiveScreen=NameofScreen)
      Button1.Visible: App.ActiveScreen=NameofScreen
  • audrieFCT Profile Picture
    987 on at

    Thank you for responding so quickly! I will give that a try and then post results here. Note: I want the button to stay hidden until they close the app. When they reopen the app the button will be visible again, until they click it. They are allowed to use that button only once per session (it's triggering a Microsoft Flow).

     

    Thank you again, I promise to let you know if that works today,

    Audrie

  • Brian Dang Profile Picture
    3,976 on at

    If you want the button to only be pressed once during the whole app usage, it may be best to use one variable.

     

    Button1.OnSelect: UpdateContext({hasbeenpressed: true})
    Button1.Disabled: hasbeenpressed

    Name the variable whatever you want. It starts off as false. It turns true once it is pressed. There is no way for it to turn back.

     

    You may want to put some additional conditions on it so that users don't mess up their one chance:

    Button1.OnSelect: If(yourconditionshere, UpdateContext({hasbeenpressed: true}))

    Or prevent them from being able to push the button if conditions are not met

    Button1.Disabled: hasbeenpressed || !(yourconditionshere)
  • audrieFCT Profile Picture
    987 on at

    Thanks for thinking ahead regarding users that might make a mistake. I'm trying it now.

  • audrieFCT Profile Picture
    987 on at

    That worked perfectly! You're a genius!

  • Beuferd Profile Picture
    55 on at

    Greetings.

    I have a similar question, but based on a drop down box that is prepopulated from sharepoint.

    I have a screen, with two data connections.  The permissions are different for each list.

    This screen has two prepopulated drop down boxes-  Jobs, PremJobs. 

    ALL my users need to see Jobs and only some of them need to see PremJobs.

    So far, everything works EXCEPT-

    When the PremJobs is automatically disabled based on user permission- I would llike the card to disapear from the screen. 

    I can't figure it out.  I think it has to do with the visible control and variables, just don't know the way to go about it.

    any help will be appreciated.

    thanks so much.

     

  • Quinten Miller Profile Picture
    5 on at

    Hi Carlos,

     

    I'm curious to know why as to why a variable is required in this instance? 

     

    I've been trying to set the visibility of a camera control with something on long the lines the following within the OnSelect of an Icon

     

    CameraControl.Visible = true

     

    Now I'm having to introduce a variable where it would seem one is not required. 

     

    I'm interested in what is happening under the hood of PowerApps - for interests sake 🙂

     

    Cheers

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard