adamdriscoll / poshprotools

PowerShell Pro Tools and Universal Dashboard
https://ironmansoftware.com/
104 stars 24 forks source link

No Form.Designer.ps1 equivalent for WPF App #21

Open pldmgg opened 7 years ago

pldmgg commented 7 years ago

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?

adamdriscoll commented 7 years ago

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?

pldmgg commented 7 years ago

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...

adamdriscoll commented 7 years ago

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.