Completely hide WPF window on startup?

南笙酒味 提交于 2020-01-12 02:49:06

问题


I want that my window is completely hidden on the startup. No window, no entry in the taskbar. The user doesn't see, the application is started.

How can I realize that?

Thank you!


回答1:


An alternative to H.B.'s method is just to set the Visibility to hidden and set ShowInTaskbar to false. This still creates the window and lets it do its thing.

<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" ShowInTaskbar="False" Visibility="Hidden">
    <Grid>

    </Grid>
</Window>



回答2:


Don't show the window. By default there is a StartupUri defined in the App.xaml, remove it and override the OnStartup method in the code-behind to create a window, just Show and Hide it as you wish.




回答3:


Simply don't create a window, just delete the StartupUri from App.xaml.

It might be helpful to set the Application to ShutDownMode="OnExplicitShutdown" this will prevent that your application shuts down if your last window was closed.



来源:https://stackoverflow.com/questions/6690848/completely-hide-wpf-window-on-startup

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!