开发者

Expanding silverlight combobox control upside?

开发者 https://www.devze.com 2023-03-23 07:37 出处:网络
Is there a way to change the expanding orientation to upside of a combobox control in silverlight instead of downside?

Is there a way to change the expanding orientation to upside of a combobox control in silverlight instead of downside?

What i mean is think of youtube's video quality combobox its o开发者_StackOverflow中文版penning from bottom to top (the combo box to select 240p, 340p etc..).. If i put the combobox in the bottom of layout its openning upside as default but is there a way to achieve this in any other place?


You'll need to use a attached behaviour, since the Silverlight popup control of the ComboBox doesn't have the Placement property. A example of such behaviour can be found here: Silverlight Popup with Target Placement

Then all you have to do is to apply a style, where you attach the behaviour to the Popup:

<Style x:Key="ComboBoxStyle1" TargetType="ComboBox">
    ... snip ...
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ComboBox">
                <Grid>
                    ... snip ...

                    <!-- Attach behaviour here! -->
                    <Popup x:Name="Popup">
                        <Border x:Name="PopupBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3" HorizontalAlignment="Stretch" Height="Auto">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                    <GradientStop Color="#FFFEFEFE" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <ScrollViewer x:Name="ScrollViewer" BorderThickness="0" Padding="1">
                                <ItemsPresenter/>
                            </ScrollViewer>
                        </Border>
                    </Popup>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
0

精彩评论

暂无评论...
验证码 换一张
取 消