Esempio n. 1
0
        public void Selected_Index_Is_Maintained_Carousel_Created_With_Non_Zero_SelectedIndex()
        {
            var items = new ObservableCollection <string>
            {
                "Foo",
                "Bar",
                "FooBar"
            };

            var target = new Carousel
            {
                Template      = new FuncControlTemplate <Carousel>(CreateTemplate),
                Items         = items,
                IsVirtualized = false,
                SelectedIndex = 2
            };

            target.ApplyTemplate();
            target.Presenter.ApplyTemplate();

            Assert.Equal("FooBar", target.SelectedItem);

            var child = target.GetVisualDescendants().LastOrDefault();

            Assert.IsType <TextBlock>(child);
            Assert.Equal("FooBar", ((TextBlock)child).Text);
        }