Browse Source

Added DropDown.MaxDropDownHeight.

Fixes #654.
pull/650/merge
Steven Kirk 10 years ago
parent
commit
e894df344c
  1. 15
      src/Avalonia.Controls/DropDown.cs
  2. 15
      src/Avalonia.Themes.Default/DropDown.xaml

15
src/Avalonia.Controls/DropDown.cs

@ -28,6 +28,12 @@ namespace Avalonia.Controls
o => o.IsDropDownOpen,
(o, v) => o.IsDropDownOpen = v);
/// <summary>
/// Defines the <see cref="MaxDropDownHeight"/> property.
/// </summary>
public static readonly StyledProperty<double> MaxDropDownHeightProperty =
AvaloniaProperty.Register<DropDown, double>(nameof(MaxDropDownHeight), 200);
/// <summary>
/// Defines the <see cref="SelectionBoxItem"/> property.
/// </summary>
@ -56,6 +62,15 @@ namespace Avalonia.Controls
set { SetAndRaise(IsDropDownOpenProperty, ref _isDropDownOpen, value); }
}
/// <summary>
/// Gets or sets the maximum height for the dropdown list.
/// </summary>
public double MaxDropDownHeight
{
get { return GetValue(MaxDropDownHeightProperty); }
set { SetValue(MaxDropDownHeightProperty, value); }
}
/// <summary>
/// Gets or sets the item to display as the control's content.
/// </summary>

15
src/Avalonia.Themes.Default/DropDown.xaml

@ -30,16 +30,19 @@
Data="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z"/>
</ToggleButton>
<Popup Name="PART_Popup"
IsOpen="{TemplateBinding Path=IsDropDownOpen, Mode=TwoWay}"
MinWidth="{TemplateBinding Path=Bounds.Width}"
IsOpen="{TemplateBinding IsDropDownOpen, Mode=TwoWay}"
MinWidth="{TemplateBinding Bounds.Width}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
PlacementTarget="{TemplateBinding}"
StaysOpen="False">
<Border BorderBrush="{StyleResource ThemeBorderMidBrush}"
BorderThickness="1">
<ItemsPresenter Name="PART_ItemsPresenter"
Items="{TemplateBinding Items}"
ItemTemplate="{TemplateBinding ItemTemplate}"
MemberSelector="{TemplateBinding MemberSelector}"/>
<ScrollViewer>
<ItemsPresenter Name="PART_ItemsPresenter"
Items="{TemplateBinding Items}"
ItemTemplate="{TemplateBinding ItemTemplate}"
MemberSelector="{TemplateBinding MemberSelector}"/>
</ScrollViewer>
</Border>
</Popup>
</Grid>

Loading…
Cancel
Save