@Gilmour ,
There can be a solution , but you can implement it only on a data source that support CountRows() function (like DataVerse) or on a collection.
The main problem is that you don't know what is the number of the item selected by user. So, you need to alter the Items data by adding a column for this info (I call it "Index"). My example is based on default gallery items in powerapps (CustomGallerySample).
Set Gallery1 Items to:
ForAll(
Sequence(CountRows(CustomGallerySample)),
Patch(
Index(
CustomGallerySample,
Value
),
{Index: Value}
)
)
Having the index column, the outside control Y property will be:
Gallery1.Y+(Gallery1.Selected.Index-1)*Gallery1.TemplateHeight+(Gallery1.Selected.Index)*Gallery1.TemplatePadding
I didn't took in consideration a relative Y dimension of a control inside Gallery you want to align with. For that the formula should be:
Gallery1.Y+(Gallery1.Selected.Index-1)*Gallery1.TemplateHeight+(Gallery1.Selected.Index)*Gallery1.TemplatePadding + ControlInsideGallery.Y
Hope it helps !