Fubzot
Fubzot

Reputation: 177

Specifying Silverlight combobox popup direction (dropup)

Is it possible to make the silverlight combo-box "drop up" i.e. display the popup above the combo-box instead of bellow as per default?

Upvotes: 3

Views: 1731

Answers (1)

Mart
Mart

Reputation: 5788

The first step is to define your own ComboBox Template, that contains the definition of the Popup. Edit a copy using Blend for example.

However, placing that Popup above is not an easy task as Silverlight Popups have no Placementor PlacementTarget properties like in WPF that would allow to display it above.

Luckily Kent Boogaart wrote an Attached Behavior that adds this capability and it is used like this:

<Popup b:PopupPlacement.PlacementTarget="{Binding ElementName=ContentPresenterBorder}">
    <b:Popup.PreferredOrientations>
        <b:PopupOrientationCollection>
            <b:PopupOrientation Placement="Top" HorizontalAlignment="Center"/>
            <b:PopupOrientation Placement="Bottom" HorizontalAlignment="Center"/>
            <b:PopupOrientation Placement="Right" VerticalAlignment="Center"/>
            <b:PopupOrientation Placement="Right" VerticalAlignment="TopCenter"/>
        </b:PopupOrientationCollection>
    </b:Popup.PreferredOrientations>

    <!--Popup content with the ItemPresenter-->
</Popup>

Where ContentPresenterBorder is the name of the container that holds the ToggleButton of the ComboBox.

Upvotes: 2

Related Questions