This example shows how to close a UXWindow.
Example
Description
In ClientUI windowing framework, closing a window will permanently destroy the window and free the allocated resources used by the window. Consequently, closing a window is not identical to hiding a window as the implemention is significantly different. You need to carefully design your application and decide whether a particular window should be permanently closed instead of collapsed. You can consider to permanently close a window if the window contains a relatively large amount of objects.
There are also several important factors that determine whether a window will be hidden or closed when initiated by users in the runtime, for example, when users clicked on the "X" button of the window, which are explained in the following:
- If a window is re-createable, closing the window from user interface will destroy the window instance permanently. Otherwise, the window will only be collapsed (hidden) visually.
- A window is determined to be re-createable when it meet the following scenarios:
- The window is one of the following types: UXDialogBox or UXMessageBox.
- The WindowID or the GroupName property of the window is not empty.
- The window is of UXNavigationWindow type and created by UXDesktop through API or command.
- The window implements IApplicationHost interface and its ApplicationUri property is not empty.
- Generally, a window cannot be recreated when it is defined directly within the desktop control
The following example shows how to close a window by calling the Close method.
Code
C# | ![]() |
---|---|
private void UXButton1_Click(object sender, RoutedEventArgs e) { // Finds the specified window in the UXDesktop IWindow window = desktop1.FindWindow("UXWindow1"); // Close the window, if found. if (window != null) window.Close(); } |