private (IDisposable Subscription, Memory<ViewPosition> Views) GetPositions()
{
var refs = Children.SelectToArray(c => (View: c, Handle: GCHandle.Alloc(c, GCHandleType.Normal)));
return (
Disposable.Create(() => refs.ForEach(c => c.Handle.Free())),
refs
.SelectToMemory(c =>
new ViewPosition(
c.Handle,
new GridPosition(
Grid.GetColumn(c.View),
Grid.GetRow(c.View),
Grid.GetColumnSpan(c.View),
Grid.GetRowSpan(c.View)
)
)
)
);
}