cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Newbie12
Helper V
Helper V

Align buttons based on userseclection in PowerApps

Hi,

 

I have 2 screens with Excel Table as DataSource.

Screen 1 contains Systems Gallery ex "Sys1","Sys2","Sys3" in tile forms. These tiles are colored based on System status. Available=Green, In Use= Yellow and OOS=Red. When Enduser clicks on "Available" [Green] tile, it navigates to Screen 2, Which has 3 buttons "Sign up","Update Status" and "Cancel". Screen 2 is Summary screens about systems. So I used Display form.

 

Next, Let's say when enduser clicks on tile "In Use" or "OOS" then It should only display "Update Status" and "Cancel" button, and the buttons should be aligned at the center on the screen.

 

I played with visible properties of  Signup button, to display correct buttons using below code. I am not sure how to align buttons for other statues.

 

If (DataCardValue1.Text="Available",true",false)

 

Any help is appreciated!

Thanks in advance!

2 ACCEPTED SOLUTIONS

Accepted Solutions
RandyHayes
Super User
Super User

@Newbie12 

You can center a control on the screen with the following formula on the X property of the control:

(App.ActiveScreen.Width / 2) - (Self.Width / 2)

 

If you only have at any point one button displayed, then this should be fine.  If not, then you will need to base the formula off of the Visible property of the other buttons.

Also, if you will only have one button displayed at a time, then you might also consider just using one button.

 

As for your Visible formula, you can shorten to : DataCardValue1.Text="Available"  This will already return true or false - no need to add an If statement to return the same.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Dutchmann
Frequent Visitor

Hi there @Newbie12 

 

I made a small example for you to see if this is what you want:

Btn Placement.gif

Your case would work a bit differently but the end result would be the same. The placement has been done by making use of this resource: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/create-responsive-layout

 

The update status Y position is linked to the visibility of the Sign Up button: 

If(btnSignUp.Visible,btnSignUp.Y+Self.Height*1.5,(Parent.Height-Self.Height)/2-Self.Height)

 So what this does is first off checking what the value is of btnSignUp.Visible. That is either 'True' or 'False'. When true, the update button Y will start at the Y position of the Sign up button + the height of itself times 1.5, so you have some spacing. 

 

The cancel button is linked to the update status button like this: 

btnUpdate.Y + Self.Height*1.5

 

Screen1 onvisible would be set to 

set(gblSignupVisible,false)

 

Then the onselect for Available needs to have the following added: 

set(gblSignupVisible,true)

 

Lastly, at screen 2, set the visible property of the sign up button to gblSignupVisible.

 

 

Let me know if this worked for you.

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@Newbie12 

You can center a control on the screen with the following formula on the X property of the control:

(App.ActiveScreen.Width / 2) - (Self.Width / 2)

 

If you only have at any point one button displayed, then this should be fine.  If not, then you will need to base the formula off of the Visible property of the other buttons.

Also, if you will only have one button displayed at a time, then you might also consider just using one button.

 

As for your Visible formula, you can shorten to : DataCardValue1.Text="Available"  This will already return true or false - no need to add an If statement to return the same.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Dutchmann
Frequent Visitor

Hi there @Newbie12 

 

I made a small example for you to see if this is what you want:

Btn Placement.gif

Your case would work a bit differently but the end result would be the same. The placement has been done by making use of this resource: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/create-responsive-layout

 

The update status Y position is linked to the visibility of the Sign Up button: 

If(btnSignUp.Visible,btnSignUp.Y+Self.Height*1.5,(Parent.Height-Self.Height)/2-Self.Height)

 So what this does is first off checking what the value is of btnSignUp.Visible. That is either 'True' or 'False'. When true, the update button Y will start at the Y position of the Sign up button + the height of itself times 1.5, so you have some spacing. 

 

The cancel button is linked to the update status button like this: 

btnUpdate.Y + Self.Height*1.5

 

Screen1 onvisible would be set to 

set(gblSignupVisible,false)

 

Then the onselect for Available needs to have the following added: 

set(gblSignupVisible,true)

 

Lastly, at screen 2, set the visible property of the sign up button to gblSignupVisible.

 

 

Let me know if this worked for you.

Thanks @Dutchmann and @RandyHayes. Both solution worked fine!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (4,031)