Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

How to get views to render correctly in custom view content pages?

$
0
0

creating my own custom content page, which is more or less like a tabbed page - the child pages work perfectly,
I'm now stuck on the chrome bit.. you see I want to be able allow users of this page of mine to do something like this

<myCustomContentPage>
   <children>
      <aPage ... />
      <aPage2 ... />
      <aPage3 ... />
   </children>
   <footer>
      <stackLayout ... horizontal..etc><button /> <button /> <label /> <etc.. /> </stackLayout>
   </footer>
</myCustomContentPage>

This is working, but the stack layout doesn't correctly render the children (they are all hidden, and with zero sizes) - I verified this with the reveal app.

Here's my code for adding the footer, from my iOS renderer:

        private void UpdateFooterView (VisualElement footerVisualElement)
        {
            var factory = RendererFactory.GetRenderer (footerVisualElement);
            var footerView = factory.NativeView;
            var bounds = View.Bounds;
            footerView.Frame = new CGRect (0, bounds.Height - 100, bounds.Width, 100);
            View.AddSubview (footerView);
        }

and here's my test rig code (from my main app):

            var loginPage = (Page)ViewFactory.CreatePage<LoginPageViewModel, LoginPage> ();
            var page = new MainNavigtionPage{ };
            page.Pages = new Page[]{ loginPage };

            var stackLayout = new StackLayout () {
                Orientation = StackOrientation.Horizontal,
                Spacing = 10,
                BackgroundColor = Color.Green,
                Children = {
                    new Label () { Text = device.Display.ToString () },
                    new Label () { Text = string.Format ("Screen width is\t {0:0.0} inches.", device.Display.ScreenWidthInches ()) },
                    new Label () { Text = string.Format ("Screen height is\t {0:0.0} inches.", device.Display.ScreenHeightInches ()) },
                    new Label () { Text = string.Format ("Screen diagonal size is\t {0:0.0} inches.", device.Display.ScreenSizeInches ()) }
                }
            };
            page.FooterView = stackLayout;
            MainPage = page;

I get the same with or without setting the orientation.
if I change page.footerview to any individual control, that get's rendered fine - it seems it somehow doesn't want to do do anything with the children.

Would greatly appreciate help on this, or advice on how else I could achieve the same effect.


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>