From 324785f2539e494b200109ffb7144c919bfb80b2 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 25 Jul 2015 20:56:07 +0200 Subject: [PATCH] Documented ScrollBar. --- Perspex.Controls/Primitives/ScrollBar.cs | 44 +++++++++++++++++++++--- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/Perspex.Controls/Primitives/ScrollBar.cs b/Perspex.Controls/Primitives/ScrollBar.cs index 3936f3d535..34d240f101 100644 --- a/Perspex.Controls/Primitives/ScrollBar.cs +++ b/Perspex.Controls/Primitives/ScrollBar.cs @@ -11,23 +11,41 @@ namespace Perspex.Controls.Primitives using System.Reactive.Linq; using Perspex.Controls.Templates; + /// + /// A scrollbar control. + /// public class ScrollBar : RangeBase { + /// + /// Defines the property. + /// public static readonly PerspexProperty ViewportSizeProperty = - PerspexProperty.Register("ViewportSize", defaultValue: double.NaN); + PerspexProperty.Register(nameof(ViewportSize), defaultValue: double.NaN); + /// + /// Defines the property. + /// public static readonly PerspexProperty VisibilityProperty = - PerspexProperty.Register("Visibility"); + PerspexProperty.Register(nameof(Visibility)); + /// + /// Defines the property. + /// public static readonly PerspexProperty OrientationProperty = - PerspexProperty.Register("Orientation"); + PerspexProperty.Register(nameof(Orientation)); + /// + /// Initializes static members of the class. + /// static ScrollBar() { Control.PseudoClass(OrientationProperty, x => x == Orientation.Horizontal, ":horizontal"); Control.PseudoClass(OrientationProperty, x => x == Orientation.Vertical, ":vertical"); } + /// + /// Initializes a new instance of the class. + /// public ScrollBar() { var isVisible = Observable.Merge( @@ -39,41 +57,59 @@ namespace Perspex.Controls.Primitives this.Bind(ScrollBar.IsVisibleProperty, isVisible, BindingPriority.Style); } + /// + /// Gets or sets the amount of the scrollable content that is currently visible. + /// public double ViewportSize { get { return this.GetValue(ViewportSizeProperty); } set { this.SetValue(ViewportSizeProperty, value); } } + /// + /// Gets or sets a value that indicates whether the scrollbar should hide itself when it + /// is not needed. + /// public ScrollBarVisibility Visibility { get { return this.GetValue(VisibilityProperty); } set { this.SetValue(VisibilityProperty, value); } } + /// + /// Gets or sets the orientation of the scrollbar. + /// public Orientation Orientation { get { return this.GetValue(OrientationProperty); } set { this.SetValue(OrientationProperty, value); } } + /// protected override Size MeasureOverride(Size availableSize) { return base.MeasureOverride(availableSize); } + /// protected override void OnTemplateApplied() { base.OnTemplateApplied(); - // Binding between this.Value and track.Value must be done explicitly like this rather + // Binding between this.Value and track.Value must be done explicitly like this rather // than using standard bindings as it shouldn't be able to to be overridden by binding // e.g. ScrollBar.Value. + // TODO: This is probably no longer true. Test and use a standard 2 way binding if + // possible. var track = this.GetTemplateChild("track"); track.GetObservable(ValueProperty).Subscribe(x => this.Value = x); this.GetObservable(ValueProperty).Subscribe(x => track.Value = x); } + /// + /// Calculates whether the scrollbar should be visible. + /// + /// The scrollbar's visibility. private bool CalculateIsVisible() { switch (this.Visibility)