Reply
Level: Powered On
Posts: 5
Registered: ‎09-20-2017

Change background color of gallery card OnHover or OnSelect

Hello everyone,

 

I did a search, but while other posts pointed me in the right direction, I haven't come across anything spot-on yet.

 

I have inputted a gallery with a list of items. Ideally, I'm hoping that I could change the background of the individual "cards" on mouse-over. However, I don't see that property available. So, I have two questions:

 

1. Is OnHover (or a workaround available)?

2. If not, how could I accomplish a background color change OnSelect?

 

Thanks,

Community Support Team
Posts: 2,646
Registered: ‎10-09-2016

Re: Change background color of gallery card OnHover or OnSelect

Hi @Marc314,

 

Firstly, I'd like to explain that cards are the building blocks of the Edit form and Display form controls, not galleries. Galleries contain all kinds of controls. To change background color of these controls, you could use the HoverFill property. But not all controls support this property

 

HoverFill – The background color of a control when the user keeps the mouse pointer on it.

Applies to Add picture, Button, Check box, Drop down, Export, Icon, Image, Import, Label, List Box, Microphone, Radio, Shape, Text input, and Timer controls.

 

For you reference about Color properties in PowerApps:

https://powerapps.microsoft.com/en-us/tutorials/properties-color-border/

 

Regards,

Mona

 

 

 

Highlighted
Level: Powered On
Posts: 24
Registered: ‎11-01-2017

Re: Change background color of gallery card OnHover or OnSelect

Hi v-monli-msft- I dont think your answer is what is being requested.  Yes it is true that Cards are only used on forms, but here it is the Gallery that is being discussed and how a hoverFill can be associated with it.

 

Now the color of the selected item is controlled by the Gallery TemplateFill property by using something like the following:

 

If(
    ThisItem.IsSelected,
    White
    Green
)

 

But if you look through the Gallery's properties you will notice that there is no HoverFill property.

 

A workaround if you have only one Label displayed for each item in the gallery is to make the label the same size as the Gallery template and then set the Label's HoverFill property as desired. To do this set the label's Width property should be set to Parent.TemplateWidth and Height to Parent.TemplateHeight.

 

What to do if you have more than one label I'm not sure!  I have tried a few different hacks but nothing works properly. I think what is needed is a Gallery "isHovered property" so that it can be used with the TemplateFill property to fill the template when hovered over.

 

If anyone knows the answer please let me know!