コード例 #1
0
        private void ValueInject(DataRow drv)
        {
            DataColumnCollection dcc = Items.Columns;

            mainTabControl.ApplyTemplate();

            for (int i = 0; i < dcc.Count; i++)
            {
                object find = LogicalTreeHelper.FindLogicalNode(mainTabControl, dcc[i].ToString());
                Console.WriteLine("now find name: " + dcc[i].ToString());
                if (find != null)
                {
                    WrapPanel wpe    = find as WrapPanel;
                    TextBox   txtbox = LogicalTreeHelper.FindLogicalNode(wpe, "TxtBox") as TextBox;
                    Console.WriteLine("now text " + drv[dcc[i].ToString()]);
                    Console.WriteLine("now text type " + drv[dcc[i].ToString()].GetType());
                    if (drv[dcc[i].ToString()] != null && drv[dcc[i].ToString()].ToString().Length > 0)
                    {
                        txtbox.Text = drv[dcc[i].ToString()].ToString();
                    }
                    else
                    {
                        txtbox.Text = "";
                    }
                }
            }
            nowtab = 0;
        }
コード例 #2
0
        public void Setting_SelectedItem_Should_Set_SelectedTab()
        {
            var target = new TabControl
            {
                Template = new ControlTemplate <TabControl>(CreateTabControlTemplate),
                Items    = new[]
                {
                    new TabItem
                    {
                        Name    = "first",
                        Content = "foo",
                    },
                    new TabItem
                    {
                        Name    = "second",
                        Content = "bar",
                    },
                }
            };

            target.ApplyTemplate();
            target.SelectedItem = target.Items.Cast <TabItem>().ElementAt(1);

            Assert.Same(target.SelectedTab, target.SelectedItem);
        }
コード例 #3
0
ファイル: TabControlTests.cs プロジェクト: jorik041/Perspex
        public void Non_IHeadered_Control_Items_Should_Be_Ignored()
        {
            var items = new[]
            {
                new TextBlock {
                    Text = "foo"
                },
                new TextBlock {
                    Text = "bar"
                },
            };

            var target = new TabControl
            {
                Template = new FuncControlTemplate <TabControl>(CreateTabControlTemplate),
                Items    = items,
            };

            target.ApplyTemplate();

            var result = target.TabStrip.GetLogicalChildren()
                         .OfType <TabStripItem>()
                         .Select(x => x.Content)
                         .ToList();

            Assert.Equal(new object[] { string.Empty, string.Empty }, result);
        }
コード例 #4
0
        public void Setting_SelectedItem_Should_Set_SelectedTab()
        {
            var target = new TabControl
            {
                Template = new ControlTemplate<TabControl>(CreateTabControlTemplate),
                Items = new[]
                {
                    new TabItem
                    {
                        Name = "first",
                        Content = "foo",
                    },
                    new TabItem
                    {
                        Name = "second",
                        Content = "bar",
                    },
                }
            };

            target.ApplyTemplate();
            target.SelectedItem = target.Items.Cast<TabItem>().ElementAt(1);

            Assert.Same(target.SelectedTab, target.SelectedItem);
        }
コード例 #5
0
        public void First_Tab_Should_Be_Selected_By_Default()
        {
            TabItem selected;
            var     target = new TabControl
            {
                Template = TabControlTemplate(),
                Items    = new[]
                {
                    (selected = new TabItem
                    {
                        Name = "first",
                        Content = "foo",
                    }),
                    new TabItem
                    {
                        Name    = "second",
                        Content = "bar",
                    },
                }
            };

            target.ApplyTemplate();

            Assert.Equal(0, target.SelectedIndex);
            Assert.Equal(selected, target.SelectedItem);
        }
コード例 #6
0
ファイル: TabControlTests.cs プロジェクト: abdelkarim/Perspex
        public void First_Tab_Should_Be_Selected_By_Default()
        {
            TabItem selected;
            var target = new TabControl
            {
                Template = new FuncControlTemplate<TabControl>(CreateTabControlTemplate),
                Items = new[]
                {
                    (selected = new TabItem
                    {
                        Name = "first",
                        Content = "foo",
                    }),
                    new TabItem
                    {
                        Name = "second",
                        Content = "bar",
                    },
                }
            };

            target.ApplyTemplate();

            Assert.Equal(0, target.SelectedIndex);
            Assert.Equal(selected, target.SelectedItem);
        }
コード例 #7
0
        public void Removal_Should_Set_Next_Tab()
        {
            var collection = new ObservableCollection <TabItem>()
            {
                new TabItem
                {
                    Name    = "first",
                    Content = "foo",
                },
                new TabItem
                {
                    Name    = "second",
                    Content = "bar",
                },
                new TabItem
                {
                    Name    = "3rd",
                    Content = "barf",
                },
            };

            var target = new TabControl
            {
                Template = TabControlTemplate(),
                Items    = collection,
            };

            target.ApplyTemplate();
            target.SelectedItem = collection[1];
            collection.RemoveAt(1);

            // compare with former [2] now [1] == "3rd"
            Assert.Same(collection[1], target.SelectedItem);
        }
コード例 #8
0
ファイル: TabControlTests.cs プロジェクト: jorik041/Perspex
        public void DataContexts_Should_Be_Correctly_Set()
        {
            var items = new object[]
            {
                "Foo",
                new Item("Bar"),
                new TextBlock {
                    Text = "Baz"
                },
                new TabItem {
                    Content = "Qux"
                },
                new TabItem {
                    Content = new TextBlock {
                        Text = "Bob"
                    }
                }
            };

            var target = new TabControl
            {
                Template      = new FuncControlTemplate <TabControl>(CreateTabControlTemplate),
                DataContext   = "Base",
                DataTemplates = new DataTemplates
                {
                    new FuncDataTemplate <Item>(x => new Button {
                        Content = x
                    })
                },
                Items = items,
            };

            target.ApplyTemplate();

            var carousel = (Carousel)target.Pages;

            var dataContext = ((TextBlock)carousel.Presenter.Panel.GetLogicalChildren().Single()).DataContext;

            Assert.Equal(items[0], dataContext);

            target.SelectedIndex = 1;
            dataContext          = ((Button)carousel.Presenter.Panel.GetLogicalChildren().Single()).DataContext;
            Assert.Equal(items[1], dataContext);

            target.SelectedIndex = 2;
            dataContext          = ((TextBlock)carousel.Presenter.Panel.GetLogicalChildren().Single()).DataContext;
            Assert.Equal("Base", dataContext);

            target.SelectedIndex = 3;
            dataContext          = ((TextBlock)carousel.Presenter.Panel.GetLogicalChildren().Single()).DataContext;
            Assert.Equal("Qux", dataContext);

            target.SelectedIndex = 4;
            dataContext          = ((TextBlock)carousel.Presenter.Panel.GetLogicalChildren().Single()).DataContext;
            Assert.Equal("Base", dataContext);
        }
コード例 #9
0
ファイル: TabControlTests.cs プロジェクト: randyammar/Perspex
        private void ApplyTemplate(TabControl target)
        {
            target.ApplyTemplate();
            var carousel = (Carousel)target.Pages;

            carousel.ApplyTemplate();
            carousel.Presenter.ApplyTemplate();
            var tabStrip = (TabStrip)target.TabStrip;

            tabStrip.ApplyTemplate();
            tabStrip.Presenter.ApplyTemplate();
        }
コード例 #10
0
        private void ApplyTemplate(TabControl target)
        {
            target.ApplyTemplate();

            target.Presenter.ApplyTemplate();

            foreach (var tabItem in target.GetLogicalChildren().OfType <TabItem>())
            {
                tabItem.Template = TabItemTemplate();

                tabItem.ApplyTemplate();

                ((ContentPresenter)tabItem.Presenter).UpdateChild();
            }

            target.ContentPart.ApplyTemplate();
        }
コード例 #11
0
        public void Logical_Child_Should_Be_Selected_Tab_Content()
        {
            var target = new TabControl
            {
                Template = new ControlTemplate <TabControl>(CreateTabControlTemplate),
                Items    = new[]
                {
                    new TabItem
                    {
                        Content = "foo"
                    },
                    new TabItem
                    {
                        Content = "bar"
                    },
                },
            };

            target.ApplyTemplate();

            Assert.Equal(1, target.GetLogicalChildren().Count());
            Assert.Equal("foo", ((TextBlock)target.GetLogicalChildren().First()).Text);
        }
コード例 #12
0
ファイル: TabControlTests.cs プロジェクト: Robertofon/Perspex
        public void Logical_Child_Should_Be_SelectedContent()
        {
            var target = new TabControl
            {
                Template = new ControlTemplate<TabControl>(this.CreateTabControlTemplate),
                Items = new[]
                {
                    new TabItem
                    {
                        Content = "foo"
                    },
                    new TabItem
                    {
                        Content = "bar"
                    },
                },
            };

            target.ApplyTemplate();

            Assert.Equal(1, target.GetLogicalChildren().Count());
            Assert.Equal("foo", ((TextBlock)target.GetLogicalChildren().First()).Text);
        }
コード例 #13
0
ファイル: TabControlTests.cs プロジェクト: abdelkarim/Perspex
        public void Logical_Children_Should_Be_TabItems()
        {
            var items = new[]
            {
                new TabItem
                {
                    Content = "foo"
                },
                new TabItem
                {
                    Content = "bar"
                },
            };

            var target = new TabControl
            {
                Template = new FuncControlTemplate<TabControl>(CreateTabControlTemplate),
                Items = items,
            };

            Assert.Equal(items, target.GetLogicalChildren());
            target.ApplyTemplate();
            Assert.Equal(items, target.GetLogicalChildren());
        }
コード例 #14
0
        public void Logical_Children_Should_Be_TabItems()
        {
            var items = new[]
            {
                new TabItem
                {
                    Content = "foo"
                },
                new TabItem
                {
                    Content = "bar"
                },
            };

            var target = new TabControl
            {
                Template = TabControlTemplate(),
                Items    = items,
            };

            Assert.Equal(items, target.GetLogicalChildren());
            target.ApplyTemplate();
            Assert.Equal(items, target.GetLogicalChildren());
        }
コード例 #15
0
ファイル: TabControlTests.cs プロジェクト: MarkWalls/Perspex
        public void Setting_SelectedTab_Should_Set_SelectedItem()
        {
            var target = new TabControl
            {
                Template = ControlTemplate.Create<TabControl>(this.CreateTabControlTemplate),
                Items = new[]
                {
                    new TabItem
                    {
                        Name = "first"
                    },
                    new TabItem
                    {
                        Name = "second"
                    },
                }
            };

            target.ApplyTemplate();
            target.SelectedTab = target.Items.Cast<TabItem>().ElementAt(1);

            Assert.Same(target.SelectedItem, target.SelectedTab);
        }
コード例 #16
0
ファイル: TabControlTests.cs プロジェクト: Arlorean/Perspex
        public void Non_IHeadered_Control_Items_Should_Be_Ignored()
        {
            var items = new[]
            {
                new TextBlock { Text = "foo" },
                new TextBlock { Text = "bar" },
            };

            var target = new TabControl
            {
                Template = new FuncControlTemplate<TabControl>(CreateTabControlTemplate),
                Items = items,
            };

            target.ApplyTemplate();

            var result = target.TabStrip.GetLogicalChildren()
                .OfType<TabStripItem>()
                .Select(x => x.Content)
                .ToList();

            Assert.Equal(new object[] { string.Empty, string.Empty }, result);
        }
コード例 #17
0
        public void DataContexts_Should_Be_Correctly_Set()
        {
            var items = new object[]
            {
                "Foo",
                new Item("Bar"),
                new TextBlock { Text = "Baz" },
                new TabItem { Content = "Qux" },
                new TabItem { Content = new TextBlock { Text = "Bob" } }
            };

            var target = new TabControl
            {
                Template = new FuncControlTemplate<TabControl>(CreateTabControlTemplate),
                DataContext = "Base",
                DataTemplates = new DataTemplates
                {
                    new FuncDataTemplate<Item>(x => new Button { Content = x })
                },
                Items = items,
            };

            target.ApplyTemplate();

            var dataContext = ((TextBlock)target.GetLogicalChildren().Single()).DataContext;
            Assert.Equal(items[0], dataContext);

            target.SelectedIndex = 1;
            dataContext = ((Button)target.GetLogicalChildren().Single()).DataContext;
            Assert.Equal(items[1], dataContext);

            target.SelectedIndex = 2;
            dataContext = ((TextBlock)target.GetLogicalChildren().Single()).DataContext;
            Assert.Equal("Base", dataContext);

            target.SelectedIndex = 3;
            dataContext = ((TextBlock)target.GetLogicalChildren().Single()).DataContext;
            Assert.Equal("Qux", dataContext);

            target.SelectedIndex = 4;
            dataContext = ((TextBlock)target.GetLogicalChildren().Single()).DataContext;
            Assert.Equal("Base", dataContext);
        }
コード例 #18
0
ファイル: TabControlTests.cs プロジェクト: Robertofon/Perspex
        public void SelectedContent_Should_Initially_Be_First_Tab_Content()
        {
            var target = new TabControl
            {
                Template = new ControlTemplate<TabControl>(this.CreateTabControlTemplate),
                Items = new[]
                {
                    new TabItem
                    {
                        Name = "first",
                        Content = "foo",
                    },
                    new TabItem
                    {
                        Name = "second",
                        Content = "bar",
                    },
                }
            };

            target.ApplyTemplate();

            Assert.Equal("foo", target.SelectedContent);
        }
コード例 #19
0
ファイル: TabControlTests.cs プロジェクト: abdelkarim/Perspex
        public void Removal_Should_Set_Next_Tab()
        {
            var collection = new ObservableCollection<TabItem>()
            {
                new TabItem
                {
                    Name = "first",
                    Content = "foo",
                },
                new TabItem
                {
                    Name = "second",
                    Content = "bar",
                },
                new TabItem
                {
                    Name = "3rd",
                    Content = "barf",
                },
            };

            var target = new TabControl
            {
                Template = new FuncControlTemplate<TabControl>(CreateTabControlTemplate),
                Items = collection,
            };

            target.ApplyTemplate();
            target.SelectedItem = collection[1];
            collection.RemoveAt(1);

            // compare with former [2] now [1] == "3rd"
            Assert.Same(collection[1], target.SelectedItem);
        }
コード例 #20
0
ファイル: TabControlTests.cs プロジェクト: abdelkarim/Perspex
 private void ApplyTemplate(TabControl target)
 {
     target.ApplyTemplate();
     var carousel = (Carousel)target.Pages;
     carousel.ApplyTemplate();
     carousel.Presenter.ApplyTemplate();
     var tabStrip = (TabStrip)target.TabStrip;
     tabStrip.ApplyTemplate();
     tabStrip.Presenter.ApplyTemplate();
 }