C#/WPF:将弹出窗口控件放置在屏幕中央吗? [英] C#/WPF: Place Popup Control in Center of Screen?

查看:97
本文介绍了C#/WPF:将弹出窗口控件放置在屏幕中央吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道我如何在屏幕中央放置弹出控件吗?

Does anyone know how I can place a Popup Control in the Center of the screen?

谢谢!

推荐答案

使用Placement和PlacementTarget属性将其相对于位于窗口根部的任何面板定位.因此,如果我的GridStackPanel等包含称为MainPanel的窗口中的所有其他东西",我会执行以下操作:

Use the Placement and PlacementTarget properties to position it relative to whatever panel is at the root of the window. So if I have a Grid, StackPanel, etc. that contains all the other "stuff" in the window called MainPanel, I do something like:

<Popup
    PlacementTarget="{Binding ElementName=MainPanel}"
    Placement="Center"
>

这篇关于C#/WPF:将弹出窗口控件放置在屏幕中央吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆