cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Choose a specific text in a gallery

Hi,

I have a gallery of texts and a button, each time i add an element to the gallery, i have a new text added to the gallery with a new button, the thing is I want to change the color of the text when i click on the specified button, but when i do, all the texts change color, so how can i link the button to its related text ?

Thank you, i hope i have been clear

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Anonymous ,

 

In the OnVisible property of the Screen, set a variable Set(varTextColor, false).

In the OnSelect property of the Button, update the variable UpdateContext({varTextColor: !varTextColor})

In the Color property of the Text Control, If(ThisItem.IsSelected && varTextColor, Red, Black)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

20 REPLIES 20
pawanjajoo
Resolver I
Resolver I

Hi @Anonymous ,

 

Can you please share some screenshots and formulas that you are currently using? Based on the explanation you have provided, it would seem that you are using a Gallery control. You can set the text color for the control in the "OnSelect" property of Button control for the row.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

LooseChippings
Advocate II
Advocate II

Hi @Anonymous 

 

You need to have two properties to make sure only the the selected item color changes.  So, the logic is something like "If this item is selected and the Button is pressed, make the text Red, otherwise make the text Black".

 

As @pawanjajoo  has said, you haven't given enough information to be accurate but the code in your Color property of the text would be something like 'If(ThisItem.IsSelected && Button1Pressed = true, Red, Black)'

 

Anonymous
Not applicable

Yes I have a gallery control with rows, and each time someone add a new element through forms, a new row is created, but when i want to change the color of the text of the row with its related button ( in the same row ), all the texts change color.

 

On the button  select part I'm using : UpdateContext({var: RGBA(255,255,0,100)})

and on the  text fill part i have : var

Hi @Anonymous ,

 

As mentioned by @LooseChippings , you need to use If condition to ensure that the variable is applied only to selected item. Since you have not applied any condition, on click of button, it is updating the color for all the rows.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Anonymous
Not applicable

But I only click on the button, the text is not selected, is it alright ?

Hi @Anonymous ,

 

Yes, that's all right. You don't need to select the text. ThisItem.Selected just refers to that particular row in the gallery.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Anonymous
Not applicable

My button name is " NextArrow1 ", so what i need to do is to write on the color part of the text : If(ThisItem.IsSelected && NextArrow1 = true, Red, Black)' ? Should I add some code on the button too ? 

 

Im sorry im really new to all of this so im not sure what to do

Hi @Anonymous ,

 

In the OnVisible property of the Screen, set a variable Set(varTextColor, false).

In the OnSelect property of the Button, update the variable UpdateContext({varTextColor: !varTextColor})

In the Color property of the Text Control, If(ThisItem.IsSelected && varTextColor, Red, Black)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Anonymous
Not applicable

It works, but I press the other button, the color of the other row go back to normal. Do you know how to fix it ? 

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,197)