Skip to content

Commit

Permalink
ScrolledWindow needs to be resized on its parent allocation, and forc…
Browse files Browse the repository at this point in the history
…e its content to be updated too
  • Loading branch information
sescalada committed Jun 23, 2017
1 parent 13fa627 commit 110013f
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion Xamarin.Forms.Platform.GTK/Renderers/ScrollViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
using System;
using System.ComponentModel;
using Xamarin.Forms.Platform.GTK.Extensions;
using Xamarin.Forms.Platform.GTK.Helpers;

namespace Xamarin.Forms.Platform.GTK.Renderers
{
public class ScrollViewRenderer : ViewRenderer<ScrollView, ScrolledWindow>
{
private VisualElement _currentView;
private Viewport _viewPort;
private Gdk.Rectangle _lastAllocation;

protected IScrollViewController Controller
{
Expand Down Expand Up @@ -57,6 +57,40 @@ protected override void OnElementChanged(ElementChangedEventArgs<ScrollView> e)
}
}

protected override void OnSizeAllocated(Gdk.Rectangle allocation)
{
base.OnSizeAllocated(allocation);

if (IsAnimationRunning(Element))
{
return;
}

if (_lastAllocation != allocation)
{
_lastAllocation = allocation;

Rectangle bounds = Element.Bounds;
Container.MoveTo((int)bounds.X, (int)bounds.Y);

for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
var child = ElementController.LogicalChildren[i] as VisualElement;

if (child != null)
{
var renderer = Platform.GetRenderer(child);
renderer?.Container.SetSize(child.Bounds.Width, child.Bounds.Height);

if (!IsAnimationRunning(renderer.Element))
{
renderer?.Container.MoveTo(child.Bounds.X, child.Bounds.Y);
}
}
}
}
}

protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
Expand Down

0 comments on commit 110013f

Please sign in to comment.