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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,518)