Browse Source

Set dropdown popup min width.

pull/39/head
Steven Kirk 12 years ago
parent
commit
57dab3d7d0
  1. 19
      Perspex.Controls/Popup.cs
  2. 2
      Perspex.Themes.Default/DropDownStyle.cs

19
Perspex.Controls/Popup.cs

@ -76,9 +76,17 @@ namespace Perspex.Controls
{ {
if (this.popupRoot == null) if (this.popupRoot == null)
{ {
this.popupRoot = new PopupRoot(); this.popupRoot = new PopupRoot()
this.popupRoot.Parent = this; {
this.popupRoot[~PopupRoot.ContentProperty] = this[~ChildProperty]; Parent = this,
[~PopupRoot.ContentProperty] = this[~ChildProperty],
[~PopupRoot.WidthProperty] = this[~WidthProperty],
[~PopupRoot.HeightProperty] = this[~HeightProperty],
[~PopupRoot.MinWidthProperty] = this[~MinWidthProperty],
[~PopupRoot.MaxWidthProperty] = this[~MaxWidthProperty],
[~PopupRoot.MinHeightProperty] = this[~MinHeightProperty],
[~PopupRoot.MaxHeightProperty] = this[~MaxHeightProperty],
};
} }
this.popupRoot.SetPosition(this.GetPosition()); this.popupRoot.SetPosition(this.GetPosition());
@ -101,6 +109,11 @@ namespace Perspex.Controls
this.IsOpen = false; this.IsOpen = false;
} }
protected override Size MeasureCore(Size availableSize)
{
return new Size();
}
protected override void OnAttachedToVisualTree(IRenderRoot root) protected override void OnAttachedToVisualTree(IRenderRoot root)
{ {
base.OnAttachedToVisualTree(root); base.OnAttachedToVisualTree(root);

2
Perspex.Themes.Default/DropDownStyle.cs

@ -7,6 +7,7 @@
namespace Perspex.Themes.Default namespace Perspex.Themes.Default
{ {
using System.Linq; using System.Linq;
using System.Reactive.Linq;
using Perspex.Controls; using Perspex.Controls;
using Perspex.Controls.Presenters; using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives; using Perspex.Controls.Primitives;
@ -89,6 +90,7 @@ namespace Perspex.Themes.Default
PlacementTarget = control, PlacementTarget = control,
StaysOpen = false, StaysOpen = false,
[~~Popup.IsOpenProperty] = control[~~DropDown.IsDropDownOpenProperty], [~~Popup.IsOpenProperty] = control[~~DropDown.IsDropDownOpenProperty],
[~Popup.MinWidthProperty] = control[~DropDown.ActualSizeProperty].Cast<Size>().Select(x => (object)x.Width),
} }
}, },
}, },

Loading…
Cancel
Save