简体   繁体   English

需要在WPF的顶部显示usercontrol

[英]Need to show usercontrol on the top in WPF

I have a user control that I am using for some purpose and it's movable on the screen. 我有一个用户控件,我出于某种目的使用它,它可以在屏幕上移动。 Actually I am creating an application using Leap Motion. 实际上我正在使用Leap Motion创建一个应用程序。 SO wherever I move my figure on the screen a big circular cursor moves accordingly. 因此,无论我在屏幕上移动我的身材,大圆形光标都会相应移动。 But on some place it gets cut off or I would say it gets hide or overlapped due to some other controls. 但是在某些地方它会被切断,或者我会说它会因为其他一些控件而被隐藏或重叠。 So I want to know, how can I placed it on the top of the mainwindow view. 所以我想知道,我怎么能把它放在主窗口视图的顶部。 Is it possible using adorner layer? 是否可以使用装饰层? If yes, So can you please tell me how to do that in WPF? 如果是的话,那么请你告诉我如何在WPF中做到这一点?

I found few examples on net but they are creating a rectangle or some thing on adorner layer using drwaingcontext object, however I just need to show my user control on the top. 我在网上发现了一些例子,但是他们使用drwaingcontext对象在adorner层上创建了一个矩形或一些东西,但是我只需要在顶部显示我的用户控件。

Please give me some idea 请给我一些想法

Thanks & Regards, Vinod 谢谢和问候,Vinod

You shouldn't need to use the Adorner layer to simply show a UserControl on top of other controls... of course that depends on exactly what is 'overlapping' or hiding it. 你不应该使用Adorner层来简单地在其他控件之上显示UserControl ......当然这取决于究竟什么是“重叠”或隐藏它。 If they are just other UI controls, then you can fix your problem in two ways. 如果它们只是其他UI控件,那么您可以通过两种方式解决问题。

The first is to simply declare your UserControl that you want to be on top of the other controls at the bottom of the XAML, eg. 第一种是简单地声明你想要在XAML底部的其他控件之上的UserControl ,例如。 define that element last. 最后定义该元素。

The second solution is to use the Panel.ZIndex Attached Property to place that element above all others: 第二种解决方案是使用Panel.ZIndex Attached Property将该元素放在所有其他元素之上:

<UserControl Panel.ZIndex="10" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM