Browse Source

Added doc comments for ScrollViewer.

pull/330/head
Steven Kirk 10 years ago
parent
commit
6dc9ee31e0
  1. 118
      src/Perspex.Controls/ScrollViewer.cs

118
src/Perspex.Controls/ScrollViewer.cs

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

Loading…
Cancel
Save