开发者

Is it possible to draw on top of a WPF ComboBox dropdown?

I'm working on a program that records user input, and it is useful to be able to decorate the UI components that the mouse is over by drawing a box around them.

I do this by creating a transparent window over the top of the program I'm recording and drawing in that window.

This works for most programs, but draws underneath ComboBox dropdowns. It looks like the dropdown is a window with the topmost style set.

I've tried setting my decoration window to be topmost also, and the dropdown still draws over it. If I periodically set my decoration window to be topmost and active, the dropdown closes when I activate the decoration window. I've tried setting the Popup.StaysOpen property of the Popup containing the dropdown menu, but that has no effect.

Is there any way for me to draw over the dropdown menu wi开发者_Go百科thout modifying the menu itself?

Thanks.


Maybe the Adorner Layer, which is always above anything else, is the best solution?


Have you tried using a Popup Control instead of a Window? I believe it is drawn on the same layer as the ComboBox DropDown, so you should be able set the ZIndex to draw overtop of the DropDown.

You can set a ComboBox's popup ZIndex by adding a Style to the ComboBox

<ComboBox>
    <ComboBox.Resources>
        <Style TargetType={x:Type ComboBox}>
            <Setter Property="Canvas.ZIndex" Value="1" />
        </Style>
    </ComboBox.Resources>
<ComboBox>


I was able to get this working by setting my window's ShowActivated to false, then setting it Topmost after the popup had opened.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜