poshprotools icon indicating copy to clipboard operation
poshprotools copied to clipboard

No Form.Designer.ps1 equivalent for WPF App

Open pldmgg opened this issue 7 years ago • 3 comments

Started a new PowerShell Script project in Visual Studio 2017. Then did Add New Item -> WPF Window (Beta). Pasted some XAML in there. The designer view GUI updated, but I couldn't find a file with corresponding code similar to how Form.Designer.ps1 auto-populated for a Windows Form project.

Is this functionality coming in the future?

pldmgg avatar Sep 05 '17 15:09 pldmgg

The XAML designer does not produce a designer.ps1 file. The XAML is actually loaded at runtime and the code-behind is hooked to the controls in that manner. If you use bundling, it will encode the XAML as base64 and include it with the script but it's not exactly the same thing you're looking for.

What would you expect in the designer file?

adamdriscoll avatar Sep 05 '17 16:09 adamdriscoll

I guess I was expecting the form controls to be exposed in PowerShell somehow. Something like the section "BEGIN/END Form Control Methods" section around line 467 in my NoClutter-NetworkMonitor.ps1 WPF App:

https://github.com/pldmgg/misc-powershell/blob/master/GUI_Apps/WPF/NoClutter-NetworkMonitor/NoClutter-NetworkMonitor.ps1

Or maybe they're already exposed by PoshToolsPro somehow? I just don't know how to reference them in my Script.ps1...

pldmgg avatar Sep 05 '17 16:09 pldmgg

Ah. Yeah I see what you mean. Right now the controls are added to the code behind script when you wire up an event handler. I've had another user ask that all controls, regardless of whether they have an event handler, are available to the script.

adamdriscoll avatar Sep 05 '17 16:09 adamdriscoll