是否可以使 silverlight 组合框“下拉”,即在组合框上方显示弹出窗口,而不是默认显示在下方?
最佳答案
第一步是定义您自己的组合框模板,其中包含弹出窗口的定义。例如,使用 Blend 编辑副本。
但是,将该 Popup 放置在上方并不是一件容易的任务,因为 Silverlight Popups 没有像 WPF 中那样允许在上方显示的 Placement
或 PlacementTarget
属性。
幸运的是Kent Boogaart wrote an Attached Behavior添加了此功能,其使用方式如下:
<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>
其中 ContentPresenterBorder
是保存 ComboBox 的 ToggleButton 的容器的名称。
关于silverlight - 指定 Silverlight 组合框弹出方向(下拉),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5153582/