diff --git a/src/Perspex.Controls/ScrollViewer.cs b/src/Perspex.Controls/ScrollViewer.cs index 2d7da90ac1..5af724a614 100644 --- a/src/Perspex.Controls/ScrollViewer.cs +++ b/src/Perspex.Controls/ScrollViewer.cs @@ -8,50 +8,127 @@ using Perspex.Controls.Primitives; namespace Perspex.Controls { + /// + /// A control scrolls its content if the content is bigger than the space available. + /// public class ScrollViewer : ContentControl { + /// + /// Defines the property. + /// + public static readonly PerspexProperty CanScrollHorizontallyProperty = + PerspexProperty.RegisterAttached(nameof(CanScrollHorizontally), true); + + /// + /// Defines the property. + /// public static readonly PerspexProperty ExtentProperty = - PerspexProperty.Register("Extent"); + PerspexProperty.Register(nameof(Extent)); + /// + /// Defines the property. + /// public static readonly PerspexProperty OffsetProperty = - PerspexProperty.Register("Offset", validate: ValidateOffset); + PerspexProperty.Register(nameof(Offset), validate: ValidateOffset); + /// + /// Defines the property. + /// public static readonly PerspexProperty ViewportProperty = - PerspexProperty.Register("Viewport"); - + PerspexProperty.Register(nameof(Viewport)); + + /// + /// Defines the HorizontalScrollBarMaximum property. + /// + /// + /// There is no C# accessor for this property as it is intended to be bound to by a + /// in the control's template. + /// public static readonly PerspexProperty HorizontalScrollBarMaximumProperty = PerspexProperty.Register("HorizontalScrollBarMaximum"); + /// + /// Defines the HorizontalScrollBarValue property. + /// + /// + /// There is no C# accessor for this property as it is intended to be bound to by a + /// in the control's template. + /// public static readonly PerspexProperty HorizontalScrollBarValueProperty = PerspexProperty.Register("HorizontalScrollBarValue"); + /// + /// Defines the HorizontalScrollBarViewportSize property. + /// + /// + /// There is no C# accessor for this property as it is intended to be bound to by a + /// in the control's template. + /// public static readonly PerspexProperty HorizontalScrollBarViewportSizeProperty = PerspexProperty.Register("HorizontalScrollBarViewportSize"); + /// + /// Defines the property. + /// + /// + /// There is no C# accessor for this property as it is intended to be bound to by a + /// in the control's template. + /// + public static readonly PerspexProperty HorizontalScrollBarVisibilityProperty = + PerspexProperty.RegisterAttached( + nameof(HorizontalScrollBarVisibility), + ScrollBarVisibility.Auto); + + /// + /// Defines the VerticalScrollBarMaximum property. + /// + /// + /// There is no C# accessor for this property as it is intended to be bound to by a + /// in the control's template. + /// public static readonly PerspexProperty VerticalScrollBarMaximumProperty = PerspexProperty.Register("VerticalScrollBarMaximum"); + /// + /// Defines the VerticalScrollBarValue property. + /// + /// + /// There is no C# accessor for this property as it is intended to be bound to by a + /// in the control's template. + /// public static readonly PerspexProperty VerticalScrollBarValueProperty = PerspexProperty.Register("VerticalScrollBarValue"); + /// + /// Defines the VerticalScrollBarViewportSize property. + /// + /// + /// There is no C# accessor for this property as it is intended to be bound to by a + /// in the control's template. + /// public static readonly PerspexProperty VerticalScrollBarViewportSizeProperty = PerspexProperty.Register("VerticalScrollBarViewportSize"); - public static readonly PerspexProperty CanScrollHorizontallyProperty = - PerspexProperty.RegisterAttached("CanScrollHorizontally", true); - - public static readonly PerspexProperty HorizontalScrollBarVisibilityProperty = - PerspexProperty.RegisterAttached("HorizontalScrollBarVisibility", ScrollBarVisibility.Auto); - + /// + /// Defines the property. + /// public static readonly PerspexProperty VerticalScrollBarVisibilityProperty = - PerspexProperty.RegisterAttached("VerticalScrollBarVisibility", ScrollBarVisibility.Auto); + PerspexProperty.RegisterAttached( + nameof(VerticalScrollBarVisibility), + ScrollBarVisibility.Auto); + /// + /// Initializes static members of the class. + /// static ScrollViewer() { AffectsValidation(ExtentProperty, OffsetProperty); AffectsValidation(ViewportProperty, OffsetProperty); } + /// + /// Initializes a new instance of the class. + /// public ScrollViewer() { var extentAndViewport = Observable.CombineLatest( @@ -88,36 +165,54 @@ namespace Perspex.Controls .Subscribe(x => Offset = x); } + /// + /// Gets the extent of the scrollable content. + /// public Size Extent { get { return GetValue(ExtentProperty); } private set { SetValue(ExtentProperty, value); } } + /// + /// Gets or sets the current scroll offset. + /// public Vector Offset { get { return GetValue(OffsetProperty); } set { SetValue(OffsetProperty, value); } } + /// + /// Gets the size of the viewport on the scrollable content. + /// public Size Viewport { get { return GetValue(ViewportProperty); } private set { SetValue(ViewportProperty, value); } } + /// + /// Gets a value indicating whether the content can be scrolled horizontally. + /// public bool CanScrollHorizontally { get { return GetValue(CanScrollHorizontallyProperty); } set { SetValue(CanScrollHorizontallyProperty, value); } } + /// + /// Gets or sets the horizontal scrollbar visibility. + /// public ScrollBarVisibility HorizontalScrollBarVisibility { get { return GetValue(HorizontalScrollBarVisibilityProperty); } set { SetValue(HorizontalScrollBarVisibilityProperty, value); } } + /// + /// Gets or sets the vertical scrollbar visibility. + /// public ScrollBarVisibility VerticalScrollBarVisibility { get { return GetValue(VerticalScrollBarVisibilityProperty); } @@ -131,6 +226,7 @@ namespace Perspex.Controls return new Vector(Clamp(offset.X, 0, maxX), Clamp(offset.Y, 0, maxY)); } + /// protected override Size MeasureOverride(Size availableSize) { return base.MeasureOverride(availableSize);