|
395 | 395 | <format type="text/markdown"><![CDATA[
|
396 | 396 |
|
397 | 397 | ## Remarks
|
398 |
| - A <xref:System.Windows.Window> can be closed using one of several, well-known, system-provided mechanisms located in its title bar, including: |
399 | 398 |
|
400 |
| -- ALT+F4. |
| 399 | +A <xref:System.Windows.Window> can be closed using one of several, well-known, system-provided mechanisms located in its title bar, including: |
401 | 400 |
|
402 |
| -- System menu | **Close**. |
| 401 | +- ALT+F4. |
| 402 | +- System menu | **Close**. |
| 403 | +- **Close** button. |
403 | 404 |
|
404 |
| -- **Close** button. |
| 405 | +A <xref:System.Windows.Window> can also be closed using one of several well-known mechanisms within the client area that are provided by developers, including: |
405 | 406 |
|
406 |
| - A <xref:System.Windows.Window> can also be closed using one of several well-known mechanisms within the client area that are provided by developers, including: |
407 |
| -
|
408 |
| -- **File** | **Exit** on a main window. |
409 |
| -
|
410 |
| -- **File** | **Close** or a **Close** button on a child window. |
| 407 | +- **File** > **Exit** on a main window. |
| 408 | +- **File** > **Close** or a **Close** button on a child window. |
411 | 409 |
|
412 | 410 | > [!NOTE]
|
413 |
| -> **OK** and **Cancel** buttons on a dialog box are also developer-provided, although will likely set <xref:System.Windows.Window.DialogResult%2A>, which automatically closes a window that was opened by calling <xref:System.Windows.Window.ShowDialog%2A>. |
| 411 | +> **OK** and **Cancel** buttons on a dialog box are also developer-provided, although will likely set <xref:System.Windows.Window.DialogResult%2A>, which automatically closes a window that was opened by calling <xref:System.Windows.Window.ShowDialog%2A>. |
414 | 412 |
|
415 |
| - These mechanisms require you to explicitly call <xref:System.Windows.Window.Close%2A> to close a window. |
| 413 | +These mechanisms require you to explicitly call <xref:System.Windows.Window.Close%2A> to close a window. |
416 | 414 |
|
417 | 415 | > [!NOTE]
|
418 |
| -> If a window, opened by calling <xref:System.Windows.Window.ShowDialog%2A>, and with a <xref:System.Windows.Controls.Button> with its <xref:System.Windows.Controls.Button.IsCancel%2A> property set to true, will automatically close when the button is either clicked, or ESC is pressed. If the window was opened using <xref:System.Windows.Window.Show%2A>, however, <xref:System.Windows.Window.Close%2A> must be explicitly called, such as from <xref:System.Windows.Controls.Primitives.ButtonBase.Click> event handler for the <xref:System.Windows.Controls.Button>. |
| 416 | +> If a window, opened by calling <xref:System.Windows.Window.ShowDialog%2A>, and with a <xref:System.Windows.Controls.Button> with its <xref:System.Windows.Controls.Button.IsCancel%2A> property set to true, will automatically close when the button is either clicked, or ESC is pressed. If the window was opened using <xref:System.Windows.Window.Show%2A>, however, <xref:System.Windows.Window.Close%2A> must be explicitly called, such as from <xref:System.Windows.Controls.Primitives.ButtonBase.Click> event handler for the <xref:System.Windows.Controls.Button>. |
419 | 417 |
|
420 |
| - Closing a window causes the <xref:System.Windows.Window.Closing> event to be raised. If the <xref:System.Windows.Window.Closing> event isn't canceled, the following occurs: |
| 418 | +Closing a window causes the <xref:System.Windows.Window.Closing> event to be raised. If the <xref:System.Windows.Window.Closing> event isn't canceled, the following occurs: |
421 | 419 |
|
422 |
| -- The <xref:System.Windows.Window> is removed from <xref:System.Windows.Application.Windows%2A?displayProperty=nameWithType> (if an <xref:System.Windows.Application> object exists). |
| 420 | +- The <xref:System.Windows.Window> is removed from <xref:System.Windows.Application.Windows%2A?displayProperty=nameWithType> (if an <xref:System.Windows.Application> object exists). |
423 | 421 |
|
424 |
| -- The <xref:System.Windows.Window> is removed from the owner <xref:System.Windows.Window> if the owner/owned relationship was established before the owned <xref:System.Windows.Window> was shown and after the owner <xref:System.Windows.Window> was opened. |
| 422 | +- The <xref:System.Windows.Window> is removed from the owner <xref:System.Windows.Window> if the owner/owned relationship was established before the owned <xref:System.Windows.Window> was shown and after the owner <xref:System.Windows.Window> was opened. |
425 | 423 |
|
426 |
| -- The <xref:System.Windows.Window.Closed> event is raised. |
| 424 | +- The <xref:System.Windows.Window.Closed> event is raised. |
427 | 425 |
|
428 |
| -- Unmanaged resources created by the <xref:System.Windows.Window> are disposed. |
| 426 | +- Unmanaged resources created by the <xref:System.Windows.Window> are disposed. |
429 | 427 |
|
430 |
| -- If <xref:System.Windows.Window.ShowDialog%2A> was called to show the <xref:System.Windows.Window>, <xref:System.Windows.Window.ShowDialog%2A> returns. |
| 428 | +- If <xref:System.Windows.Window.ShowDialog%2A> was called to show the <xref:System.Windows.Window>, <xref:System.Windows.Window.ShowDialog%2A> returns false. |
431 | 429 |
|
432 |
| - Closing a <xref:System.Windows.Window> causes any windows that it owns to be closed. Furthermore, closing a <xref:System.Windows.Window> may cause an application to stop running depending on how the <xref:System.Windows.Application.ShutdownMode%2A?displayProperty=nameWithType> property is set. |
| 430 | + Closing a <xref:System.Windows.Window> causes any windows that it owns to be closed. Furthermore, closing a <xref:System.Windows.Window> may cause an application to stop running depending on how the <xref:System.Windows.Application.ShutdownMode%2A?displayProperty=nameWithType> property is set. |
433 | 431 |
|
434 | 432 | > [!NOTE]
|
435 |
| -> This method cannot be called when a window is hosted in a browser. |
436 |
| -
|
437 |
| -
|
| 433 | +> This method cannot be called when a window is hosted in a browser. |
438 | 434 |
|
439 | 435 | ## Examples
|
440 |
| - The following example shows a **File** | **Exit** menu being handled to explicitly call <xref:System.Windows.Window.Close%2A>. |
441 | 436 |
|
442 |
| - :::code language="xaml" source="~/snippets/csharp/System.Windows/Window/Close/MainWindow.xaml" id="Snippetwindowclosexaml"::: |
| 437 | +The following example shows a **File** > **Exit** menu being handled to explicitly call <xref:System.Windows.Window.Close%2A>. |
| 438 | +
|
| 439 | +:::code language="xaml" source="~/snippets/csharp/System.Windows/Window/Close/MainWindow.xaml" id="Snippetwindowclosexaml"::: |
443 | 440 |
|
444 |
| - :::code language="csharp" source="~/snippets/csharp/System.Windows/Window/Close/MainWindow.xaml.cs" id="Snippetwindowclosecodebehind"::: |
445 |
| - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/WindowCloseSnippets/visualbasic/mainwindow.xaml.vb" id="Snippetwindowclosecodebehind"::: |
| 441 | +:::code language="csharp" source="~/snippets/csharp/System.Windows/Window/Close/MainWindow.xaml.cs" id="Snippetwindowclosecodebehind"::: |
| 442 | +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/WindowCloseSnippets/visualbasic/mainwindow.xaml.vb" id="Snippetwindowclosecodebehind"::: |
446 | 443 |
|
447 | 444 | ]]></format>
|
448 | 445 | </remarks>
|
|
0 commit comments