Table of Contents

Class Window

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

Represents a window that makes up an application's user interface.

[ControlCategory("Hidden")]
public class Window : ContainerControl, IBaseObject, IDisposableObject, ISupportInitialize, IFocusable, ITextProperty, IComponent, INotifyDataErrorInfo, IWindow, IControl, IDisposable, IWin32Window
Inheritance
Window
Implements
Derived

Examples

Here is how to declare a Window in UIXML:

<Window xmlns="http://schemas.alternetsoft.com/ui/2021"
        xmlns:x="http://schemas.alternetsoft.com/ui/2021/uixml"
        x:Class="Alternet.UI.Documentation.Examples.Window.MainWindow"
        Title="Window" Name="window">
</Window>

Also, a Window can be created from code:

var wnd = new Alternet.UI.Window();

Remarks

A Window is a representation of any window displayed in your application. The point of interaction between a user and a standalone application is a window. A Window consists of two distinct areas:

  • A non-client area, which hosts the window adornments, including a title, minimize button, maximize button, close button, and a border.
  • A client area that hosts application-specific content.

Examples of how a Window can look on different platforms:

Set Title property to specify the title of this window.

Constructors

Window()

Initializes a new instance of the Window class.

Window(WindowKind)

Initializes a new instance of the Window class.

Properties

ActiveWindow

Gets the currently active window for this application.

BorderStyle

Gets or sets border style of the window.

CloseEnabled

Gets or sets a value indicating whether the window has an enabled close button.

ControlKind

Returns control identifier.

DefaultBounds

Gets or sets default location and position of the window.

DefaultDPI

Gets DPI of the first created window.

Handler

Gets window handler.

HasBorder

Gets or sets a value indicating whether the window has a border.

HasSystemMenu

Gets or sets whether system menu is visible for this window.

HasTitleBar

Gets or sets a boolean value indicating whether window has title bar.

Icon

Gets or sets the icon for the window.

IncFontSize

Gets or sets default control font size increment (in points) on normal dpi displays (DPI less or equal to 96). Default value is 0.

IncFontSizeHighDpi

Gets or sets default control font size increment (in points) on high dpi displays (DPI greater than 96). Default value is 2.

InputBindings

Gets the collection of input bindings associated with this window.

IsActive

Gets a value indicating whether the window is the currently active window for this application.

IsMaximized

Gets or sets whether this window is maximized.

IsMinimized

Gets or sets whether this window is minimized.

IsPopupWindow

Gets or sets a value indicating whether to create a special popup window.

IsToolWindow

A tool window does not appear in the Windows taskbar or in the window that appears when the user presses ALT+TAB. On Windows, a tool window doesn't have minimize and maximize buttons.

KeyPreview

Gets or sets a value indicating whether the form will receive key events before the event is passed to the control that has focus.

MaximizeEnabled

Gets or sets a value indicating whether the window has an enabled maximize button.

Menu

Gets or sets the MainMenu that is displayed in the window.

MinimizeEnabled

Gets or sets a value indicating whether the window has an enabled minimize button.

Modal

Gets a value indicating whether this window is displayed modally.

OwnedWindows

Gets an array of Window objects that represent all windows that are owned by this window.

Owner

Gets or sets the window that owns this window.

ProcessIdle

Gets or sets whether Idle event is fired.

Resizable

Gets or sets a value indicating whether the window can be resized by user.

ShowInTaskbar

Gets or sets a value indicating whether the form is displayed in the Windows or Linux taskbar.

StartLocation

Gets or sets the position of the window when first shown.

State

Gets or sets a value that indicates whether window is minimized, maximized, or normal.

StatusBar

Gets or sets the StatusBar that is displayed in the window.

SupressEsc

Gets or sets whether to supress 'Esc' key.

Title

Gets or sets the title of the control.

TopMost

Gets or sets a value indicating whether the window should be placed above all non-topmost windows and should stay above them, even when the window is deactivated.

Visible

Gets or sets a value indicating whether the control and all its child controls are displayed.

Methods

Activate()

Activates the window.

ApplyStartLocation(Control?)

Applies StartLocation to the location of the window.

ApplyStartLocationOnce(Control?)

Applies StartLocation to the window position if StateFlags has no StartLocationApplied flag.

BindHandlerEvents()

Binds events to the handler.

Close()

Closes the window.

CreateAs<T>(WindowKind)

Creates window with specified type and window kind.

CreateHandler()

Creates a handler for the control.

Dispose(bool)

Disposes object's resources.

GetDefaultBounds()

Gets default bounds assigned to the window.

GetWindowKind()

Gets window kind (window, dialog, etc.).

GetWindowKindOverride()

Gets window kind used instead of the default value.

OnAlwaysOnTopChanged(EventArgs)

Called when the value of the TopMost property changes.

OnCloseEnabledChanged(EventArgs)

Called when the value of the CloseEnabled property changes.

OnClosed(EventArgs)

Raises the Closed event and calls OnClosed(EventArgs). See Closed event description for more details.

OnClosing(WindowClosingEventArgs)

Raises the Closing event and calls OnClosing(WindowClosingEventArgs). See Closing event description for more details.

OnDpiChanged(DpiChangedEventArgs)

Called when the DpiChanged event is raised.

OnHandlerClosing(CancelEventArgs)

Raised by the handler when it is going to be closed.

OnHandlerInputBindingCommandExecuted(HandledEventArgs<string>)

Default InputBindingCommandExecuted event implementation.

OnHandlerLocationChanged(EventArgs)

Called when the native conrol location is changed.

OnHandlerSizeChanged(EventArgs)

Called when the native conrol size is changed.

OnHasBorderChanged(EventArgs)

Called when the value of the HasBorder property changes.

OnHasSystemMenuChanged(EventArgs)

Called when the value of the HasSystemMenu property changes.

OnHasTitleBarChanged(EventArgs)

Called when the value of the HasTitleBar property changes.

OnIconChanged(EventArgs)

Called when the value of the Icon property changes.

OnIdle(EventArgs)

Called when when the application finishes processing events and is about to enter the idle state.

OnIsToolWindowChanged(EventArgs)

Called when the value of the IsToolWindow property changes.

OnKeyDown(KeyEventArgs)

Called when the KeyDown event is raised.

OnMaximizeEnabledChanged(EventArgs)

Called when the value of the MaximizeEnabled property changes.

OnMenuChanged(EventArgs)

Called when the value of the Menu property changes.

OnMinimizeEnabledChanged(EventArgs)

Called when the value of the MinimizeEnabled property changes.

OnOwnerChanged(EventArgs)

Called when the value of the Owner property changes.

OnResizableChanged(EventArgs)

Called when the value of the Resizable property changes.

OnShowInTaskbarChanged(EventArgs)

Called when the value of the ShowInTaskbar property changes.

OnStateChanged(EventArgs)

Called when the value of the State property changes.

OnStatusBarChanged(EventArgs)

Called when the value of the StatusBar property changes.

OnSystemColorsChanged(EventArgs)

Called when the SystemColorsChanged event is raised.

OnToolBarChanged(EventArgs)

Called when the value of the ToolBar property changes.

ProcessShortcuts(KeyEventArgs)

Iterates through all child control's shortcuts and calls shortcut action if its key is pressed.

RaiseClosed(WindowClosedEventArgs)

Raises Closed event and OnClosed(EventArgs) method.

RaiseClosing(WindowClosingEventArgs)

Raises Closing event and OnClosing(WindowClosingEventArgs) method.

RaiseStateChanged()

Raises StateChanged event and OnStateChanged(EventArgs) method.

RecreateAllHandlers()

Recreates all native controls in all windows.

ShowAndFocus(bool)

Shows window and focuses it.

UnbindHandlerEvents()

Unbinds events from the handler.

UpdateDefaultFont()

Updates default control font after changes in IncFontSizeHighDpi or IncFontSize. You should not call this method directly.

Events

AlwaysOnTopChanged

Occurs when the value of the TopMost property changes.

CloseEnabledChanged

Occurs when the value of the CloseEnabled property changes.

Closed

Occurs when the window is closed.

Closing

Occurs before the window is closed.

DisplayChanged

Occurs when window moves to another display.

HasBorderChanged

Occurs when the value of the HasBorder property changes.

HasSystemMenuChanged

Occurs when the value of the HasSystemMenu property changes.

HasTitleBarChanged

Occurs when the value of the HasTitleBar property changes.

IconChanged

Occurs when the value of the Icon property changes.

IsToolWindowChanged

Occurs when the value of the IsToolWindow property changes.

MaximizeEnabledChanged

Occurs when the value of the MaximizeEnabled property changes.

MenuChanged

Occurs when the value of the Menu property changes.

MinimizeEnabledChanged

Occurs when the value of the MinimizeEnabled property changes.

OwnerChanged

Occurs when the value of the Owner property changes.

ResizableChanged

Occurs when the value of the Resizable property changes.

ShowInTaskbarChanged

Occurs when the value of the ShowInTaskbar property changes.

StateChanged

Occurs when the value of the State property changes.

StatusBarChanged

Occurs when the value of the StatusBar property changes.