How to Highlight the Selected Record in a Canvas PowerApp Gallery

Colin Maitland, 11 October 2019

In this article, I demonstrate how to highlight the selected record in a Canvas PowerApp Gallery.

The following image shows a Gallery displaying Contact records on the right and a related Detail Form showing the currently selected Contact on the left.

It is desired that the currently selected Contact also be highlighted in the Gallery as shown in the following image where the background colour is Grey for the selected Contact, Alex Wu, and White for the other Contacts.

The following formula for the TemplateFill property of the Gallery control achieves this.

This formula is evaluated for each displayed Contact and works as follows:

  • “ThisItem” is a reference to the current Gallery item being evaluated and “ThisItem.IsSelected” indicates whether that item is currently selected.

  • The RGBA statement sets the fill colour of the Gallery item being evaluated to either Gray or White depending on whether it is the currently selected Contact in the Gallery.

Finally, in order to be able to select a record in the Gallery, the Selectable property of the Gallery control must be set to true.