C#/WPF: Place Popup Control in Center of Screen?(C#/WPF:将弹出控件放在屏幕中心?)
问题描述
有谁知道如何在屏幕中央放置一个弹出控件?
Does anyone know how I can place a Popup Control in the Center of the screen?
谢谢!
推荐答案
使用 Placement 和 PlacementTarget 属性将其相对于位于窗口根部的任何面板定位.因此,如果我有一个 Grid
、StackPanel
等,其中包含名为 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:将弹出控件放在屏幕中心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C#/WPF:将弹出控件放在屏幕中心?
基础教程推荐
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- c# Math.Sqrt 实现 2022-01-01