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

Generate panorma from tabbed page

$
0
0

Our customer wants the tabbed page to be generated as a panorma on Windows Phone.

I have written code that generates a panorama, but I can't get the the content from the tabs. I got a null reference exception when I trying to ConvertPageToUIElement. Is there any way to get the content from each tab and insert into a panorama?

`public class PanoramaTabRenderer : Panorama, IVisualElementRenderer, IRegisterable
{
private VisualElement _element;
private TabbedPage _tabbedPage;

    public System.Windows.UIElement ContainerElement
    {
        get {


            return this; }
    }

    public VisualElement Element
    {
        get { return _element; }
    }

    public event EventHandler<VisualElementChangedEventArgs> ElementChanged;

    public SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
    {
        throw new NotImplementedException();
    }

    public void SetElement(VisualElement element)
    {
        _element = element;
        _tabbedPage = ((TabbedPage)element);

        this.Title = _tabbedPage.Title;


        foreach (var tab in _tabbedPage.Children)
        {
            var item = new PanoramaItem();
            item.Header = tab.Title;

            var page = new PhoneApplicationPage();

            var content = tab.ConvertPageToUIElement(page);

            item.Content = content;

            this.Items.Add(item);

        }
    }

}`

Viewing all articles
Browse latest Browse all 58056

Trending Articles