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?
Solved! Go to Solution.
You can use context variables to do that. Here's one possible implementation for your scenario (using this screen below):
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
You can use context variables to do that. Here's one possible implementation for your scenario (using this screen below):
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
@CarlosFigueira Thank you for the solution.
Also, thanks to your reply, now I understand what a Variable is.
So double thanks.
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?
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:
UpdateContext({ enabled: true, visible: true })
Button1.Disabled: !(App.ActiveScreen=NameofScreen) Button1.Visible: App.ActiveScreen=NameofScreen
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
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)
Thanks for thinking ahead regarding users that might make a mistake. I'm trying it now.
That worked perfectly! You're a genius!
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.
User | Count |
---|---|
140 | |
139 | |
77 | |
77 | |
71 |
User | Count |
---|---|
223 | |
179 | |
69 | |
67 | |
58 |