Browse Source

Set dropdown popup min width.

pull/39/head
Steven Kirk 11 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)
{
this.popupRoot = new PopupRoot();
this.popupRoot.Parent = this;
this.popupRoot[~PopupRoot.ContentProperty] = this[~ChildProperty];
this.popupRoot = new PopupRoot()
{
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());
@ -101,6 +109,11 @@ namespace Perspex.Controls
this.IsOpen = false;
}
protected override Size MeasureCore(Size availableSize)
{
return new Size();
}
protected override void OnAttachedToVisualTree(IRenderRoot root)
{
base.OnAttachedToVisualTree(root);

2
Perspex.Themes.Default/DropDownStyle.cs

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

Loading…
Cancel
Save