Skip to content

Add stable window reference - #25

Merged
RiverHeart merged 2 commits into
AppKeywordfrom
AddStableWindowReference
Jun 13, 2026
Merged

Add stable window reference#25
RiverHeart merged 2 commits into
AppKeywordfrom
AddStableWindowReference

Conversation

@RiverHeart

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a stable, name-independent way to retrieve the “current” root WPF window for a DSL control context, and updates the ImageViewer example and documentation to prefer that approach over relying on a specific registered window name.

Changes:

  • Adds Get-WPFWindow (exported) to resolve the root window from $this / active context / explicit -ContextId.
  • Registers the root window into each context under the reserved name __WPFWindow from both Window and App.
  • Adds Pester coverage for Get-WPFWindow and updates docs + ImageViewer example usages accordingly.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/modules/WPF/WPF.psd1 Exports the new Get-WPFWindow helper.
src/modules/WPF/Public/Helpers/Get-WPFWindow.ps1 Implements context-based root window resolution.
src/modules/WPF/Public/DSL/Window.ps1 Registers the root window as __WPFWindow in the context table.
src/modules/WPF/Public/DSL/App.ps1 Registers the root window as __WPFWindow in the context table for app shells.
src/modules/WPF/Tests/Get-WPFWindow.Tests.ps1 Adds tests for root-window resolution across contexts and error cases.
src/modules/WPF/Examples/ImageViewer/ImageViewer.DSL.ps1 Uses Get-WPFWindow / $this instead of Reference 'Window' for root window access.
src/modules/WPF/Docs/KeywordReference.md Documents Get-WPFWindow and updates Reference examples to prefer it for root-window access.

Comment on lines +23 to +26
$ScopeObject = $PSCmdlet.GetVariableValue('this')
if ($ScopeObject -is [System.Windows.Window]) {
return $ScopeObject
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being resolved by #28

```

```powershell
$Window = Get-WPFWindow -ContextId $Window._WPFContextId
@RiverHeart
RiverHeart merged commit 1194f1e into AppKeyword Jun 13, 2026
1 check passed
@RiverHeart
RiverHeart deleted the AddStableWindowReference branch June 13, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants