C#, WPF, NET 4.0:
如果我在窗口衍生的班子上做新事,而在这个窗户上不叫Sudialog,我的节目就关闭了。
例:
Window d = new Window();
//d.ShowDialog();
为什么如此?
我不想展示窗户,我只想把这个目标用于某种目的。 因此,我必须做些什么才能允许我的方案在随后关闭?
C#, WPF, NET 4.0:
如果我在窗口衍生的班子上做新事,而在这个窗户上不叫Sudialog,我的节目就关闭了。
例:
Window d = new Window();
//d.ShowDialog();
为什么如此?
我不想展示窗户,我只想把这个目标用于某种目的。 因此,我必须做些什么才能允许我的方案在随后关闭?
您很可能将申请编成“
This setting is governed by the Application.ShutdownMode
property, which specifies the condition that causes the Shutdown
method to be called. Essentially, you have three options.
首先,正如你所见,除非和直到它创造的所有窗口都已关闭,否则你的申请不会结束。 无论是用户还是通过打电话<代码>将其关闭,都无关紧要。 近代码>方法。
这一选择通过制定<条码>申请加以规定。 ShutdownMode property to OnLastWindowClose
。
第二种方法利用了这样一个事实,即几乎所有申请都有“主要”窗口(这是你在申请启动时首先展示的窗口),而且在关闭这一主要窗口时,操作时间自动关闭了你的全部申请(和所有的儿童窗口)。 同样,窗户是否被用户关闭或通过密码关闭,也无关紧要。
这一选择通过制定<条码>申请加以规定。 ShutdownMode property to OnMainWindowClose
。
第三项选择基本上表明,你将重新进行手工管理。 在你打电话Shutdown,。 穿过代码。
This option is specified by setting the Application.ShutdownMode
property to OnExplicitShutdown
.
我建议,在这种情况下,你将“second>”办法设定为“
you can use this code to close all windows
private void CloseAllWindows()
{
foreach(var window in Application.Current.Windows)
window.Close();
}
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...