Пример #1
0
        protected ShellItem CreateShellItem(
            TemplatedPage page       = null,
            bool asImplicit          = false,
            string shellContentRoute = null,
            string shellSectionRoute = null,
            string shellItemRoute    = null,
            bool templated           = false)
        {
            ShellItem item    = null;
            var       section = CreateShellSection(page, asImplicit, shellContentRoute, shellSectionRoute, templated: templated);

            if (!String.IsNullOrWhiteSpace(shellItemRoute))
            {
                item       = new ShellItem();
                item.Route = shellItemRoute;
                item.Items.Add(section);
            }
            else if (asImplicit)
            {
                item = ShellItem.CreateFromShellSection(section);
            }
            else
            {
                item = new ShellItem();
                item.Items.Add(section);
            }

            return(item);
        }
Пример #2
0
        protected T CreateShellItem <T>(
            TemplatedPage page       = null,
            bool asImplicit          = false,
            string shellContentRoute = null,
            string shellSectionRoute = null,
            string shellItemRoute    = null,
            bool templated           = false) where T : ShellItem
        {
            T   item    = null;
            var section = CreateShellSection(page, asImplicit, shellContentRoute, shellSectionRoute, templated: templated);

            if (!String.IsNullOrWhiteSpace(shellItemRoute))
            {
                item       = Activator.CreateInstance <T>();
                item.Route = shellItemRoute;
                item.Items.Add(section);
            }
            else if (asImplicit)
            {
                item = (T)ShellItem.CreateFromShellSection(section);
            }
            else
            {
                item = Activator.CreateInstance <T>();
                item.Items.Add(section);
            }

            return(item);
        }
Пример #3
0
        public async Task TabBarAutoCreation()
        {
            Shell shell = new Shell();

            shell.Items.Add(ShellItem.CreateFromShellSection(CreateShellSection <Tab>()));
            shell.Items.Add(ShellItem.CreateFromShellSection(CreateShellSection <Tab>()));
            shell.Items.Add(ShellItem.CreateFromShellSection(CreateShellSection <Tab>()));

            Assert.AreEqual(1, shell.Items.Count);
            Assert.AreEqual(3, shell.Items[0].Items.Count);

            Assert.AreEqual(FlyoutBehavior.Disabled, shell.GetEffectiveFlyoutBehavior());


            shell = new Shell();
            shell.Items.Add(new TabBar());
            shell.Items.Add(ShellItem.CreateFromShellSection(CreateShellSection <Tab>()));
            shell.Items.Add(ShellItem.CreateFromShellSection(CreateShellSection <Tab>()));
            shell.Items.Add(ShellItem.CreateFromShellSection(CreateShellSection <Tab>()));

            Assert.AreEqual(2, shell.Items.Count);
            Assert.AreEqual(0, shell.Items[0].Items.Count);
            Assert.AreEqual(3, shell.Items[1].Items.Count);


            shell = new Shell();
            shell.Items.Add(ShellItem.CreateFromShellSection(CreateShellSection <Tab>()));
            shell.Items.Add(ShellItem.CreateFromShellSection(CreateShellSection <Tab>()));
            shell.Items.Add(ShellItem.CreateFromShellSection(CreateShellSection <Tab>()));
            shell.Items.Add(new TabBar());
            shell.Items.Add(ShellItem.CreateFromShellSection(CreateShellSection <Tab>()));
            shell.Items.Add(ShellItem.CreateFromShellSection(CreateShellSection <Tab>()));
            shell.Items.Add(ShellItem.CreateFromShellSection(CreateShellSection <Tab>()));

            Assert.AreEqual(3, shell.Items.Count);
            Assert.AreEqual(3, shell.Items[0].Items.Count);
            Assert.AreEqual(0, shell.Items[1].Items.Count);
            Assert.AreEqual(3, shell.Items[0].Items.Count);
        }