Browse Source

Make DropDown in ControlCatalog display correctly.

pull/316/merge
Steven Kirk 11 years ago
parent
commit
59032dcff8
  1. 6
      samples/ControlCatalog/Pages/CarouselPage.paml
  2. 22
      src/Perspex.Controls/DropDown.cs
  3. 1
      src/Perspex.Themes.Default/DropDown.paml

6
samples/ControlCatalog/Pages/CarouselPage.paml

@ -20,9 +20,9 @@
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock>Transition</TextBlock>
<DropDown SelectedIndex="0">
<StackPanel Orientation="Horizontal" Gap="4">
<TextBlock VerticalAlignment="Center">Transition</TextBlock>
<DropDown SelectedIndex="0" VerticalAlignment="Center">
<ListBoxItem>None</ListBoxItem>
<ListBoxItem>Slide</ListBoxItem>
<ListBoxItem>Crossfade</ListBoxItem>

22
src/Perspex.Controls/DropDown.cs

@ -83,6 +83,12 @@ namespace Perspex.Controls
return new ItemContainerGenerator<ListBoxItem>(this, ListBoxItem.ContentProperty);
}
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
{
base.OnAttachedToLogicalTree(e);
this.UpdateSelectionBoxItem(this.SelectedItem);
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
@ -149,7 +155,19 @@ namespace Perspex.Controls
private void SelectedItemChanged(PerspexPropertyChangedEventArgs e)
{
var control = e.NewValue as IControl;
UpdateSelectionBoxItem(e.NewValue);
}
private void UpdateSelectionBoxItem(object item)
{
var contentControl = item as IContentControl;
if (contentControl != null)
{
item = contentControl.Content;
}
var control = item as IControl;
if (control != null)
{
@ -169,7 +187,7 @@ namespace Perspex.Controls
}
else
{
SelectionBoxItem = e.NewValue;
SelectionBoxItem = item;
}
}
}

1
src/Perspex.Themes.Default/DropDown.paml

@ -4,6 +4,7 @@
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="4"/>
<Setter Property="Template">
<ControlTemplate>
<Border Background="{TemplateBinding Background}"

Loading…
Cancel
Save