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

UWP + Forms 2.0 - Custom Page Renderer always shows empty

$
0
0

I have below custom page renderer for UWP app, while the app always shows an empty screen, from the debug with the Loaded event, I can see the border element in the ContainerElement with ActualWidth=0 and ActualHeight = 0, I think this is why it's empty. How can I get the element on the page rendered correctly?

protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }

            this.Loaded += JobsPageRenderer_Loaded;
            var container = this.ContainerElement as Windows.UI.Xaml.Controls.Panel;
            Windows.UI.Xaml.Controls.Border border = new Windows.UI.Xaml.Controls.Border { Height = 200, Width = 200, Background = new Windows.UI.Xaml.Media.SolidColorBrush(Colors.Red) };
            container.Children.Add(border);
        }

        private void JobsPageRenderer_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            var container = this.ContainerElement as Windows.UI.Xaml.Controls.Panel;

            Windows.UI.Xaml.Controls.Border border = (Windows.UI.Xaml.Controls.Border)container.Children.First();

            border.UpdateLayout();//doesn't help

            container.UpdateLayout();//doesn't help

            //border's ActualHeight and ActualWidth are always 0
        }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



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