简体   繁体   English

将焦点锁定到窗口WPF

[英]Locking focus to a window WPF

I am adding a disclosure window to the start of my application. 我正在向应用程序的开始添加一个披露窗口。 I want the window to be the only window that the user can interact with until it is closed. 我希望该窗口成为用户可以与之交互的唯一窗口,直到将其关闭。 I have googled the heck out of it and have come up empty. 我用谷歌搜索了一下,结果空了。

Thanks, 谢谢,

Joseph 约瑟夫

You want modal dialog maybe? 您想要模态对话框吗? See ShowDialog() method. 请参见ShowDialog()方法。

For example: 例如:


App.xaml file: App.xaml文件:

<Application x:Class="WpfApplication3.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             Startup="Application_Startup" />

App.xaml.cs file: App.xaml.cs文件:

public partial class App : Application
{
    private void Application_Startup(object sender, StartupEventArgs e)
    {
        var w = new YourDisclosureWindowClass();
        w.ShowDialog();
        // whatever you need to run you entire application
    }
}

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

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