Browse Source

Make DropDown's dropdown a ListBox.

pull/39/head
Steven Kirk 11 years ago
parent
commit
adb9ce49d2
  1. 2
      Perspex.Controls/Primitives/ScrollBar.cs
  2. 2
      Perspex.Controls/Primitives/ScrollBarVisibility.cs
  3. 20
      Perspex.Controls/ScrollViewer.cs
  4. 16
      Perspex.Layout/Layoutable.cs
  5. 2
      Perspex.Themes.Default/DropDownStyle.cs

2
Perspex.Controls/Primitives/ScrollBar.cs

@ -100,7 +100,7 @@ namespace Perspex.Controls.Primitives
case ScrollBarVisibility.Auto:
var viewportSize = this.ViewportSize;
return double.IsNaN(viewportSize) || viewportSize < this.Maximum - this.Minimum;
return !double.IsNaN(viewportSize) && viewportSize < this.Maximum - this.Minimum;
default:
throw new InvalidOperationException("Invalid value for ScrollBar.Visibility.");

2
Perspex.Controls/Primitives/ScrollBarVisibility.cs

@ -8,8 +8,8 @@ namespace Perspex.Controls.Primitives
{
public enum ScrollBarVisibility
{
Auto,
Visible,
Hidden,
Auto,
}
}

20
Perspex.Controls/ScrollViewer.cs

@ -65,20 +65,20 @@ namespace Perspex.Controls
.Select(x => new { Extent = x[0], Viewport = x[1] });
this.Bind(
HorizontalScrollBarMaximumProperty,
extentAndViewport.Select(x => Math.Max(x.Extent.Width - x.Viewport.Width, 0)));
VerticalScrollBarViewportSizeProperty,
extentAndViewport.Select(x => Max((x.Viewport.Height / x.Extent.Height) * (x.Extent.Height - x.Viewport.Height), 0)));
this.Bind(
HorizontalScrollBarViewportSizeProperty,
extentAndViewport.Select(x => Math.Max((x.Viewport.Width / x.Extent.Width) * (x.Extent.Width - x.Viewport.Width), 0)));
extentAndViewport.Select(x => Max((x.Viewport.Width / x.Extent.Width) * (x.Extent.Width - x.Viewport.Width), 0)));
this.Bind(
VerticalScrollBarMaximumProperty,
extentAndViewport.Select(x => Math.Max(x.Extent.Height - x.Viewport.Height, 0)));
HorizontalScrollBarMaximumProperty,
extentAndViewport.Select(x => Max(x.Extent.Width - x.Viewport.Width, 0)));
this.Bind(
VerticalScrollBarViewportSizeProperty,
extentAndViewport.Select(x => Math.Max((x.Viewport.Height / x.Extent.Height) * (x.Extent.Height - x.Viewport.Height), 0)));
VerticalScrollBarMaximumProperty,
extentAndViewport.Select(x => Max(x.Extent.Height - x.Viewport.Height, 0)));
this.GetObservable(OffsetProperty).Subscribe(x =>
{
@ -139,6 +139,12 @@ namespace Perspex.Controls
return (value < min) ? min : (value > max) ? max : value;
}
private static double Max(double x, double y)
{
var result = Math.Max(x, y);
return double.IsNaN(result) ? 0 : Math.Round(result);
}
private static Vector CoerceOffset(PerspexObject o, Vector value)
{
ScrollViewer scrollViewer = o as ScrollViewer;

16
Perspex.Layout/Layoutable.cs

@ -221,6 +221,14 @@ namespace Perspex.Layout
{
var parent = this.GetVisualParent<ILayoutable>();
if (this.IsMeasureValid)
{
this.Log().Debug(
"Invalidated measure of {0} (#{1:x8})",
this.GetType().Name,
this.GetHashCode());
}
this.IsMeasureValid = false;
this.IsArrangeValid = false;
this.previousMeasure = null;
@ -245,6 +253,14 @@ namespace Perspex.Layout
{
var root = this.GetLayoutRoot();
if (this.IsArrangeValid)
{
this.Log().Debug(
"Invalidated arrange of {0} (#{1:x8})",
this.GetType().Name,
this.GetHashCode());
}
this.IsArrangeValid = false;
this.previousArrange = null;

2
Perspex.Themes.Default/DropDownStyle.cs

@ -81,7 +81,7 @@ namespace Perspex.Themes.Default
},
new Popup
{
Child = new ItemsControl
Child = new ListBox
{
[~ListBox.ItemsProperty] = control[~DropDown.ItemsProperty],
},

Loading…
Cancel
Save