gpt4 book ai didi

c# - 在 WPF 中的 UserControl 中设置窗口所有者

转载 作者:太空宇宙 更新时间:2023-11-03 18:09:42 25 4
gpt4 key购买 nike

我有一个 UserControl,它在任务栏中显示一个没有图标的窗口,问题是当主窗口失去焦点并再次获得焦点时,没有任务栏图标的窗口位于主窗口后面,并且很难再次在前面显示它,当类是窗口时使用 window.Owner = this; 解决了这个问题,但是当是 UserControl 或其他类型(例如 ListBoxItem, Viewbox) 我不能这样做。我尝试这样做 control.Owner = (Window)this; 但结果抛出一个异常,即 Grid 无法转换为 Window

最佳答案

使用

window.Owner = Window.GetWindow(this);

关于c# - 在 WPF 中的 UserControl 中设置窗口所有者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18306043/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com