Class WindowEx
A custom WinUI Window with more convenience methods
Inheritance
Namespace: WinUIEx
Assembly: WinUIEx.dll
Syntax
public class WindowEx : Window
Constructors
| Improve this Doc View SourceWindowEx()
Initializes a new instance of the WindowEx class.
Declaration
public WindowEx()
Properties
| Improve this Doc View SourceAppWindow
Gets a reference to the AppWindow for the app
Declaration
public AppWindow AppWindow { get; }
Property Value
Type | Description |
---|---|
AppWindow |
Height
Gets or sets the height of the window
Declaration
public double Height { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
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 |
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 |
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 |
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 |
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 |
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 |
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
| Improve this Doc View SourceMaxWidth
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
| Improve this Doc View SourceMinHeight
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
| Improve this Doc View SourceMinWidth
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
| Improve this Doc View SourcePersistenceId
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.
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
| Improve this Doc View SourcePresenterKind
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
| Improve this Doc View SourceTaskBarIcon
Gets or sets the task bar icon.
Declaration
public Icon TaskBarIcon { get; set; }
Property Value
Type | Description |
---|---|
Icon |
Title
Gets or sets the window title.
Declaration
public string Title { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Width
Gets or sets the width of the window
Declaration
public double Width { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
WindowContent
Gets or sets the Window content
Declaration
public object WindowContent { get; set; }
Property Value
Type | Description |
---|---|
System.Object | The window content. |
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
Methods
| Improve this Doc View SourceBringToFront()
Brings the window to the front
Declaration
public bool BringToFront()
Returns
Type | Description |
---|---|
System.Boolean |
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. |
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
| Improve this Doc View SourceOnSizeChanged(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
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
| Improve this Doc View SourceOnZOrderChanged(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 |
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. |
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 SourcePositionChanged
Raised if the window position changes.
Declaration
public event EventHandler<Graphics.PointInt32> PositionChanged
Event Type
Type | Description |
---|---|
System.EventHandler<Windows.Graphics.PointInt32> |
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
| Improve this Doc View SourceWindowStateChanged
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
| Improve this Doc View SourceZOrderChanged
Raised if the Z order of the window changed.
Declaration
public event EventHandler<ZOrderInfo> ZOrderChanged
Event Type
Type | Description |
---|---|
System.EventHandler<ZOrderInfo> |