Hi everyone,
I've been struggling with this for two days now and still can't seem to get it fixed.. so I hope you guys are able to help me out!
I have a page which has a WebView and a ListView. Both items are able to scroll on it's own, but I do not want that. I want the page to be fully scrollable.
This means I have to place both objects inside a ScrollView and set the .Height equal to it's contentSize.
For the WebView it was pretty easy, since it has a LoadFinished event I was able to set the Height equal to it's content.
Now I'm writing the ListView and I'm having really trouble with this. Since I am loading my data async from a webservice it seems that the contentsize of the UITableView is always 0 inside my renderer.
`public class RZNoScrollListViewRenderer : ViewRenderer<RZNoScrollTableView, UITableView>
{
private UITableView _tableView;
protected override void OnElementChanged (ElementChangedEventArgs<RZNoScrollTableView> e)
{
base.OnElementChanged (e);
if (Control == null)
return;
_tableView = Control as UITableView;
ResizeView ();
}
public override void LayoutSubviews ()
{
base.LayoutSubviews ();
ResizeView ();
}
private async void ResizeView()
{
if (_tableView != null)
{
_tableView.LayoutIfNeeded ();
var contenSizeHeight = _tableView.ContentSize.Height;
var frame = _tableView.Frame;
frame.Height = contenSizeHeight;
_tableView.Frame = frame;
var listElement = Element as RZNoScrollTableView;
var bounds = new Xamarin.Forms.Rectangle (Element.Bounds.X, Element.Bounds.Y, Element.Bounds.Width, frame.Height);
await Element.LayoutTo (bounds, listElement.TransitionSpeedMsec, listElement.Easing);
Element.HeightRequest = bounds.Height;
}
}
}`
Does anyone know how I can reach my goal?