Show / Hide Table of Contents

Class WindowEx

A custom WinUI Window with more convenience methods

Inheritance
System.Object
WindowEx
Namespace: WinUIEx
Assembly: WinUIEx.dll
Syntax
public class WindowEx : Window

Constructors

| Improve this Doc View Source

WindowEx()

Initializes a new instance of the WindowEx class.

Declaration
public WindowEx()

Properties

| Improve this Doc View Source

AppWindow

Gets a reference to the AppWindow for the app

Declaration
public AppWindow AppWindow { get; }
Property Value
Type Description
AppWindow
| Improve this Doc View Source

Height

Gets or sets the height of the window

Declaration
public double Height { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

IsAlwaysOnTop

Gets or sets a value indicating whether this window is always on top.

Declaration
public bool IsAlwaysOnTop { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsMaximizable

Gets or sets a value indicating whether the maximimze button is visible

Declaration
public bool IsMaximizable { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsMinimizable

Gets or sets a value indicating whether the minimize button is visible

Declaration
public bool IsMinimizable { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsResizable

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

Declaration
public bool IsResizable { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsShownInSwitchers

Gets or sets a value indicating whether this window is shown in task switchers.

Declaration
public bool IsShownInSwitchers { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsTitleBarVisible

Gets or sets a value indicating whether the default title bar is visible or not.

Declaration
public bool IsTitleBarVisible { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsVisibleInTray

Gets or sets a value indicating whether the window is shown in the system tray.

Declaration
public bool IsVisibleInTray { get; set; }
Property Value
Type Description
System.Boolean
Remarks

The system tray icon will use the same icon as Window's Taskbar icon, and tooltip will match the AppWindow.Title value. Double-clicking the icon restores the window if minimized and brings it to the front.

See SetIsShownInSwitchers(UI.Xaml.Window, Boolean) to hide the window from the Alt+Tab switcher and task bar. If you want to minimize the window to the tray, set this to true and on WindowStateChanged changes to minimized, hide it from the switcher.

| Improve this Doc View Source

MaxHeight

Gets or sets the maximum height of this window

Declaration
public double MaxHeight { get; set; }
Property Value
Type Description
System.Double

The maximum window height in device independent pixels.

Remarks

The default is 0, which means no limit. If the value is less than MinHeight, the MinHeight will also be used as the maximum height.

See Also
MaxWidth
MinHeight
| Improve this Doc View Source

MaxWidth

Gets or sets the maximum width of this window

Declaration
public double MaxWidth { get; set; }
Property Value
Type Description
System.Double

The maximum window width in device independent pixels.

Remarks

The default is 0, which means no limit. If the value is less than MinWidth, the MinWidth will also be used as the maximum width.

See Also
MaxHeight
MinWidth
| Improve this Doc View Source

MinHeight

Gets or sets the minimum height of this window

Declaration
public double MinHeight { get; set; }
Property Value
Type Description
System.Double

The minimum window height in device independent pixels.

Remarks

A window is currently set to a minimum of 39 pixels.

See Also
MaxHeight
MinWidth
| Improve this Doc View Source

MinWidth

Gets or sets the minimum width of this window

Declaration
public double MinWidth { get; set; }
Property Value
Type Description
System.Double

The minimum window width in device independent pixels.

Remarks

A window is currently set to a minimum of 139 pixels.

See Also
MaxWidth
MinHeight
| Improve this Doc View Source

PersistenceId

Gets or sets a unique ID used for saving and restoring window size and position across sessions.

Declaration
public string PersistenceId { get; set; }
Property Value
Type Description
System.String
Remarks

The ID must be set before the window activates. The window size and position will only be restored if the monitor layout hasn't changed between application settings. The property uses ApplicationData storage, and therefore is currently only functional for packaged applications.

| Improve this Doc View Source

Presenter

Gets the presenter for the current window

Declaration
public UI.Windowing.AppWindowPresenter Presenter { get; }
Property Value
Type Description
Microsoft.UI.Windowing.AppWindowPresenter
See Also
PresenterKind
PresenterChanged
| Improve this Doc View Source

PresenterKind

Gets or sets the presenter kind for the current window

Declaration
public UI.Windowing.AppWindowPresenterKind PresenterKind { get; set; }
Property Value
Type Description
Microsoft.UI.Windowing.AppWindowPresenterKind
See Also
Presenter
PresenterChanged
| Improve this Doc View Source

TaskBarIcon

Gets or sets the task bar icon.

Declaration
public Icon TaskBarIcon { get; set; }
Property Value
Type Description
Icon
| Improve this Doc View Source

Title

Gets or sets the window title.

Declaration
public string Title { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

Width

Gets or sets the width of the window

Declaration
public double Width { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

WindowContent

Gets or sets the Window content

Declaration
public object WindowContent { get; set; }
Property Value
Type Description
System.Object

The window content.

| Improve this Doc View Source

WindowState

Gets or sets the current window state.

Declaration
public WindowState WindowState { get; set; }
Property Value
Type Description
WindowState

A WindowState that determines whether a window is restored, minimized, or maximized. The default is Normal (restored).

Remarks

When the WindowState property is changed, WindowStateChanged is raised.

note

This property only has affect when using the OverlappedPresenter.

See Also
WindowStateChanged
PresenterKind
OnStateChanged(WindowState)

Methods

| Improve this Doc View Source

BringToFront()

Brings the window to the front

Declaration
public bool BringToFront()
Returns
Type Description
System.Boolean
| Improve this Doc View Source

OnPositionChanged(Graphics.PointInt32)

Called when the window position changed.

Declaration
protected virtual void OnPositionChanged(Graphics.PointInt32 position)
Parameters
Type Name Description
Windows.Graphics.PointInt32 position

The current position of the window in screen coordinates.

| Improve this Doc View Source

OnPresenterChanged(UI.Windowing.AppWindowPresenter)

Called when the presenter for the window changed.

Declaration
protected virtual void OnPresenterChanged(UI.Windowing.AppWindowPresenter newPresenter)
Parameters
Type Name Description
Microsoft.UI.Windowing.AppWindowPresenter newPresenter

The new presenter.

See Also
Presenter
PresenterKind
| Improve this Doc View Source

OnSizeChanged(Foundation.Size)

Called when the size of the window changes.

Declaration
protected virtual bool OnSizeChanged(Foundation.Size newSize)
Parameters
Type Name Description
Windows.Foundation.Size newSize

The new size of the window in device independent units.

Returns
Type Description
System.Boolean

True if the resize event should be marked handled.

Remarks

While this event is equivalent to the event, the units provided here are in device independent units and not screen pixels.

| Improve this Doc View Source

OnStateChanged(WindowState)

Called when the WindowState changed.

Declaration
protected virtual void OnStateChanged(WindowState state)
Parameters
Type Name Description
WindowState state

The new window state

See Also
WindowStateChanged
WindowState
| Improve this Doc View Source

OnZOrderChanged(ZOrderInfo)

Called when the Z order of the window changed.

Declaration
protected virtual void OnZOrderChanged(ZOrderInfo info)
Parameters
Type Name Description
ZOrderInfo info

Object describing the current new ZOrder of the window

| Improve this Doc View Source

ShowMessageDialogAsync(String, IList<UI.Popups.IUICommand>, UInt32, UInt32, String)

Shows a message dialog

Declaration
public async Task<UI.Popups.IUICommand> ShowMessageDialogAsync(string content, IList<UI.Popups.IUICommand> commands, uint defaultCommandIndex = 0U, uint cancelCommandIndex = 1U, string title = "")
Parameters
Type Name Description
System.String content

The message displayed to the user.

System.Collections.Generic.IList<Windows.UI.Popups.IUICommand> commands

an array of commands that appear in the command bar of the message dialog. These commands makes the dialog actionable.

System.UInt32 defaultCommandIndex

The index of the command you want to use as the default. This is the command that fires by default when users press the ENTER key.

System.UInt32 cancelCommandIndex

The index of the command you want to use as the cancel command. This is the command that fires when users press the ESC key.

System.String title

The title to display on the dialog, if any.

Returns
Type Description
System.Threading.Tasks.Task<Windows.UI.Popups.IUICommand>

An object that represents the asynchronous operation.

| Improve this Doc View Source

ShowMessageDialogAsync(String, String)

Shows a message dialog

Declaration
public Task ShowMessageDialogAsync(string content, string title = "")
Parameters
Type Name Description
System.String content

The message displayed to the user.

System.String title

The title to display on the dialog, if any.

Returns
Type Description
System.Threading.Tasks.Task

An object that represents the asynchronous operation.

Events

| Improve this Doc View Source

PositionChanged

Raised if the window position changes.

Declaration
public event EventHandler<Graphics.PointInt32> PositionChanged
Event Type
Type Description
System.EventHandler<Windows.Graphics.PointInt32>
| Improve this Doc View Source

PresenterChanged

Raised if the presenter for the window changed.

Declaration
public event EventHandler<UI.Windowing.AppWindowPresenter> PresenterChanged
Event Type
Type Description
System.EventHandler<Microsoft.UI.Windowing.AppWindowPresenter>
See Also
Presenter
PresenterKind
| Improve this Doc View Source

WindowStateChanged

Occurs when the window's WindowState property changes.

Declaration
public event EventHandler<WindowState> WindowStateChanged
Event Type
Type Description
System.EventHandler<WindowState>
Remarks
note

This event only has affect when using the OverlappedPresenter.

See Also
WindowState
OnStateChanged(WindowState)
| Improve this Doc View Source

ZOrderChanged

Raised if the Z order of the window changed.

Declaration
public event EventHandler<ZOrderInfo> ZOrderChanged
Event Type
Type Description
System.EventHandler<ZOrderInfo>
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX