Skip to content

attkri/PSWindowUI

Repository files navigation

PSWindowUI

A PowerShell module for creating WPF-based user interfaces for data querying. Define your forms declaratively via CSV and get structured results back — no XAML required.

CI PowerShell Gallery License: MIT

Install

Install-Module -Name PSWindowUI

From PowerShell Gallery.

Quick Start

Import-Module PSWindowUI

$Content = @'
ControlType;Name;Value;Required
Headline;User Data;;
TextBox;First Name;;True
TextBox;E-Mail;;True
ComboBox;Department;Engineering,Marketing,Sales;
CheckBox;Newsletter;False;
DatePicker;Start Date;;True
'@ | ConvertFrom-Csv -Delimiter ';' | New-Control

$Result = New-Window -Title 'User Form' -Content $Content -SubmitButtonText 'Save' -CancelButtonText 'Cancel'

if ($Result.DialogResult) {
    $Result.Content | Format-Table -AutoSize
}

Supported Control Types

ControlType Description Value Parameter
Headline Bold section header (not used)
TextBox Single-line text input Default text
CheckBox Boolean toggle True / False
ComboBox Dropdown selection Comma-separated items
DatePicker Date selection Date string (e.g. 2025-01-15)
RadioButton Exclusive choice (use with GroupName) True / False
PasswordBox Masked text input Default password

Parameters

New-Control

Parameter Type Default Description
ControlType Enum (req) Type of control to create
Name String (req) Label text
Value Object Initial value
ValueDelimiter String , Literal delimiter for ComboBox items
LabelWidth Int 200 Label column width in pixels
ValueWidth Int 200 Input column width in pixels
Required String '' Marks field as required. Accepts "True"/"False", $true/$false, "1"/"0". Optimized for ConvertFrom-Csv.
ValidationPattern String Regex pattern the value must match
GroupName String Group name for RadioButton mutual exclusion

New-Window

Parameter Type Default Description
Title String User Interface Window title
Height Int 700 Window height (100–2000)
Width Int 450 Window width (100–2000)
Content Grid[] (req) Controls from New-Control
SubmitButtonText String Submit Submit button label
CancelButtonText String Cancel Cancel button label

Validation

Required fields are highlighted with a red border if left empty on submit. Fields with a ValidationPattern are checked against the regex before the dialog closes.

$Content = @'
ControlType;Name;Value;Required;ValidationPattern
TextBox;E-Mail;;True;^[\w\.-]+@[\w\.-]+\.\w+$
TextBox;Phone;;False;
DatePicker;Start Date;;True;
'@ | ConvertFrom-Csv -Delimiter ';' | New-Control

$Result = New-Window -Title 'Validated Form' -Content $Content -SubmitButtonText 'Save'

Output

New-Window returns a PSCustomObject with:

  • DialogResult$true (Submit) or $false/$null (Cancel / window closed)
  • Content — Array of [PSCustomObject]@{ Id; Name; Value } for each non-headline control

Requirements

  • PowerShell 7.4 or later
  • Windows (WPF requires PresentationFramework)

License

MIT · Attila Krick

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors