Exemplo n.º 1
0
        public void Content_Is_Created()
        {
            var target = new ScrollViewer
            {
                Template = new FuncControlTemplate <ScrollViewer>(CreateTemplate),
                Content  = "Foo",
            };

            target.ApplyTemplate();

            Assert.IsType <TextBlock>(target.Presenter.Child);
        }
Exemplo n.º 2
0
        public void Content_Is_Created()
        {
            var target = new ScrollViewer
            {
                Template = new FuncControlTemplate<ScrollViewer>(CreateTemplate),
                Content = "Foo",
            };

            target.ApplyTemplate();
            ((ContentPresenter)target.Presenter).UpdateChild();

            Assert.IsType<TextBlock>(target.Presenter.Child);
        }
Exemplo n.º 3
0
        public void Content_Is_Created()
        {
            var target = new ScrollViewer
            {
                Template = new ControlTemplate <ScrollViewer>(CreateTemplate),
                Content  = "Foo",
            };

            target.ApplyTemplate();

            var presenter = target.GetTemplateChild <ScrollContentPresenter>("contentPresenter");

            Assert.IsType <TextBlock>(presenter.Child);
        }
Exemplo n.º 4
0
        public void LargeChange_Should_Come_From_ILogicalScrollable_If_Present()
        {
            var child         = new Mock <Control>();
            var logicalScroll = child.As <ILogicalScrollable>();

            logicalScroll.Setup(x => x.IsLogicalScrollEnabled).Returns(true);
            logicalScroll.Setup(x => x.PageScrollSize).Returns(new Size(45, 67));

            var target = new ScrollViewer
            {
                Template = new FuncControlTemplate <ScrollViewer>(CreateTemplate),
                Content  = child.Object,
            };

            target.ApplyTemplate();
            ((ContentPresenter)target.Presenter).UpdateChild();

            Assert.Equal(new Size(45, 67), target.LargeChange);
        }
        /*
         * Apply Templete event handler
         *
         * used to initialsed the different part of the new functionality added to the listbox control
         */
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            (Parent as UIElement).MouseLeftButtonUp += mouseLeftButtonUp;

            AddHandler(ListBox.ManipulationStartedEvent, (EventHandler <ManipulationStartedEventArgs>)listboxManipulationStarted, true);
            AddHandler(ListBox.ManipulationCompletedEvent, (EventHandler <ManipulationCompletedEventArgs>)listboxManipulationCompleted, true);
            //AddHandler(ListBox.ManipulationDeltaEvent, (EventHandler<ManipulationDeltaEventArgs>)listboxManipulationDelta, true);

            _scrollViewer = GetTemplateChild("ScrollViewer") as ScrollViewer;
            _scrollViewer.ManipulationMode = ManipulationMode.Control;
            _scrollViewer.ApplyTemplate();

            ScrollBar verticalBar = ((FrameworkElement)VisualTreeHelper.GetChild(_scrollViewer, 0)).FindName("VerticalScrollBar") as ScrollBar;

            verticalBar.ValueChanged += verticalBarValueChanged;

            _totalNumOfItems = Items.Count;
        }
Exemplo n.º 6
0
        void ScrollToOffsetCore(Point offset, Point expectedOffset, Rect expectedSlot, bool scrollable)
        {
            var          child  = ContentControlWithChild(200, 200);
            ScrollViewer viewer = new ScrollViewer {
                Content = child,
                Width   = 100,
                Height  = 100,
                HorizontalScrollBarVisibility = scrollable ? ScrollBarVisibility.Visible : ScrollBarVisibility.Disabled,
                VerticalScrollBarVisibility   = scrollable ? ScrollBarVisibility.Visible : ScrollBarVisibility.Disabled
            };

            CreateAsyncTest(viewer, () => {
                viewer.ApplyTemplate();
            }, () => {
                viewer.ScrollToHorizontalOffset(offset.X);
                viewer.ScrollToVerticalOffset(offset.Y);
            }, () => {
                ScrollContentPresenter p = Find <ScrollContentPresenter> (viewer, "ScrollContentPresenter");
                Assert.AreEqual(expectedOffset.X, p.HorizontalOffset, "#1");
                Assert.AreEqual(expectedOffset.Y, p.VerticalOffset, "#2");
            }, () => {
                Assert.AreEqual(expectedSlot, LayoutInformation.GetLayoutSlot(child), "#3");
            });
        }