Exemplo n.º 1
0
        public void ScrollBar_Should_Not_AutoHide_When_ViewportSize_Is_NaN()
        {
            var target = new ScrollBar();

            target.Visibility = ScrollBarVisibility.Auto;
            target.Minimum = 0;
            target.Maximum = 100;
            target.ViewportSize = double.NaN;

            Assert.True(target.IsVisible);
        }
Exemplo n.º 2
0
        public void ScrollBar_Should_Not_AutoHide_When_Visibility_Set_To_Visible()
        {
            var target = new ScrollBar();

            target.Visibility = ScrollBarVisibility.Visible;
            target.Minimum = 0;
            target.Maximum = 100;
            target.ViewportSize = 100;

            Assert.True(target.IsVisible);
        }
Exemplo n.º 3
0
        public void ScrollBar_Can_AutoHide()
        {
            var target = new ScrollBar();

            target.Visibility = ScrollBarVisibility.Auto;
            target.Minimum = 0;
            target.Maximum = 100;
            target.ViewportSize = 100;

            Assert.False(target.IsVisible);
        }
Exemplo n.º 4
0
        public void ScrollBar_Should_Hide_When_Visibility_Set_To_Hidden()
        {
            var target = new ScrollBar();

            target.Visibility = ScrollBarVisibility.Hidden;
            target.Minimum = 0;
            target.Maximum = 100;
            target.ViewportSize = 10;

            Assert.False(target.IsVisible);
        }
Exemplo n.º 5
0
        public void Setting_Track_Value_Should_Update_Value()
        {
            var target = new ScrollBar
            {
                Template = new FuncControlTemplate<ScrollBar>(Template),
            };

            target.ApplyTemplate();
            var track = (Track)target.GetTemplateChildren().First(x => x.Name == "track");
            track.Value = 50;

            Assert.Equal(target.Value, 50);
        }
Exemplo n.º 6
0
        public void Setting_Value_Should_Update_Track_Value()
        {
            var target = new ScrollBar
            {
                Template = new FuncControlTemplate<ScrollBar>(Template),
            };

            target.ApplyTemplate();
            var track = target.GetTemplateChild<Track>("track");
            target.Value = 50;

            Assert.Equal(track.Value, 50);
        }
Exemplo n.º 7
0
 private Control Template(ScrollBar control)
 {
     return new Border
     {
         Background = Brushes.Silver,
         Content = new Track
         {
             Name = "track",
             [~Track.MinimumProperty] = control[~ScrollBar.MinimumProperty],
             [~Track.MaximumProperty] = control[~ScrollBar.MaximumProperty],
             [~Track.ViewportSizeProperty] = control[~ScrollBar.ViewportSizeProperty],
             [~Track.OrientationProperty] = control[~ScrollBar.OrientationProperty],
             Thumb = new Thumb
             {
                 Name = "thumb",
                 Template = ControlTemplate.Create<Thumb>(this.ThumbTemplate),
             },
         },
     };
 }
Exemplo n.º 8
0
 /// <summary>
 /// The default template for the <see cref="ScrollBar"/> control.
 /// </summary>
 /// <param name="control">The control being styled.</param>
 /// <returns>The root of the instantiated template.</returns>
 public static Control Template(ScrollBar control)
 {
     return new Border
     {
         Background = Brushes.Silver,
         Child = new Track
         {
             Name = "track",
             [!Track.MinimumProperty] = control[!ScrollBar.MinimumProperty],
             [!Track.MaximumProperty] = control[!ScrollBar.MaximumProperty],
             [!!Track.ValueProperty] = control[!!ScrollBar.ValueProperty],
             [!Track.ViewportSizeProperty] = control[!ScrollBar.ViewportSizeProperty],
             [!Track.OrientationProperty] = control[!ScrollBar.OrientationProperty],
             Thumb = new Thumb
             {
                 Name = "thumb",
                 Template = new ControlTemplate<Thumb>(ThumbTemplate),
             },
         },
     };
 }
Exemplo n.º 9
0
 private static Control Template(ScrollBar control)
 {
     return new Border
     {
         Child = new Track
         {
             Name = "track",
             [!Track.MinimumProperty] = control[!RangeBase.MinimumProperty],
             [!Track.MaximumProperty] = control[!RangeBase.MaximumProperty],
             [!!Track.ValueProperty] = control[!!RangeBase.ValueProperty],
             [!Track.ViewportSizeProperty] = control[!ScrollBar.ViewportSizeProperty],
             [!Track.OrientationProperty] = control[!ScrollBar.OrientationProperty],
             Thumb = new Thumb
             {
                 Template = new FuncControlTemplate<Thumb>(ThumbTemplate),
             },
         },
     };
 }
Exemplo n.º 10
0
        private static TabItem ImagesTab()
        {
            ScrollBar size;

            return new TabItem
            {
                Header = "Images",
                Content = new StackPanel
                {
                    Orientation = Orientation.Vertical,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center,
                    Gap = 8,
                    Children = new Controls
                    {
                        (size = new ScrollBar
                        {
                            Minimum = 100,
                            Maximum = 400,
                            Value = 100,
                            Orientation = Orientation.Horizontal,
                        }),
                        new ScrollViewer
                        {
                            Width = 200,
                            Height = 200,
                            CanScrollHorizontally = true,
                            Content = new Image
                            {
                                Source = new Bitmap("github_icon.png"),
                                [!Layoutable.WidthProperty] = size[!RangeBase.ValueProperty],
                                [!Layoutable.HeightProperty] = size[!RangeBase.ValueProperty],
                            },
                        },
                        new ProgressBar
                        {
                            [!RangeBase.MinimumProperty] = size[!RangeBase.MinimumProperty],
                            [!RangeBase.MaximumProperty] = size[!RangeBase.MaximumProperty],
                            [!RangeBase.ValueProperty] = size[!RangeBase.ValueProperty],
                        }
                    }
                },
            };
        }