0
votes

can someone tell me how to edit the value for MasterBounds in XF-MasterDetailPage. My changes have no effect (MasterDetailPageRenderer/Android):

protected override void OnLayout(bool changed, int l, int t, int r, int b)
{
  base.OnLayout(changed, l, t, r, b);
  if (page != null && page.MasterBehavior == MasterBehavior.Split)
  {
    if (((IMasterDetailPageController)page).MasterBounds.Y > 0)
    {
      Rectangle rect = ((IMasterDetailPageController)page).MasterBounds;
      rect.Y = 0;
      ((IMasterDetailPageController)page).MasterBounds = rect;
    }
  }
}

I need to do this, because the value for Y is wrong on some Devices, so there is a bit of space at the top.

Thanks!

1
Have you verified with the debugger that this eventually gets called: ((IMasterDetailPageController)page).MasterBounds = rect; ?Timo Salomäki
Yes, it gets calledM.D.
Ok, have you also checked that Y really is something else than zero before you modify it?Timo Salomäki
Yes, its value is 24M.D.
I couldnt get it working, but found out that in AddView-Method there is a MasterDetailContainer with a Property called TopPadding. This value is also set, and when i change it in debugger the space on top is gone. But MDC is internal, so i cant change it in code. How to do that?M.D.

1 Answers

0
votes

In case someone else needs this, here is the solution:

public override void AddView(Android.Views.View child)
{
  child.GetType()?.GetProperty("TopPadding")?.SetValue(child, 0);
  base.AddView(child);
}