Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the ZIndex of a particular control to the topmost

Tags:

wpf

xaml

how do i set any control to the topmost of the screen. For e.g. i have a textblock in a datatemplate or a hierarchichal data template..etc... now i would like to set this textblock to the topmost on mouseover. Setting the Grid.ZIndex value to 1 in the trigger for IsMouseOver doesn't work many times. In order to do that i set the ZIndex value for all the contols to -1 in the window. it worked in one scenario but doesn't work other times.

If anyone can get me the details of ZIndex and how to set the control to the topmost without worrying about the other controls, it would be of great help.

Note: setting the value of ZIndex to a higher value e.g. 99999 also doesn't work.

like image 791
Sudhakar Singh Avatar asked Jan 09 '11 10:01

Sudhakar Singh


1 Answers

ZIndex is relative to other controls in the same Panel. A number higher than another control will ensure it appears "above" that control.

If your controls aren't all in the same Panel, ZIndex won't help you. You may need to give more information on exactly what you're doing, but it sounds like an Adorner will be of more use to you.

like image 78
Kent Boogaart Avatar answered Sep 29 '22 07:09

Kent Boogaart