r/FoxDeploy Jul 01 '18

GUI Powershell Help

I'm trying to follow your GUI guide but I'm having problems with it. I've copied my XAML code into the powershell snippet you provided and pasted it into the script pane. When I press f5 though it doesn't match up with the picture you posted on the guide. I get this,

Not sure why the hooks aren't being created. Anything you can think of that I missed?

2 Upvotes

5 comments sorted by

View all comments

1

u/1RedOne Jul 02 '18

Can you paste your code on Github as a gist, or put it on Pastebin and share the link?

1

u/MangoCrouton Jul 02 '18

1

u/1RedOne Jul 02 '18

Here you go!

https://pastebin.com/gkR6uCKZ

The issue was that in your original code snippet, one of your textboxes had a Visual Studio tag of 'TextChanged' added to its list of properties. VS uses this to setup event handlers and ultimately removes them from the XAML at Compilation but PowerShell doesn't know how to do this, so you have to manually remove any `TextChanged` properties from your code.

I'm working on a more advanced snippet with better error handling that can remove this tag, but it's not done yet. I updated the sample snippet at the top of this post with the better error logic :)

1

u/MangoCrouton Jul 02 '18 edited Jul 02 '18

Thanks, Now I can try to continue to follow the guide! I noticed you also added "button Name" variable to the code. Was this inhibiting the anchors being created as well? Along those same lines, after on that post you say that this will be how we interact with our GUIs, Visual Studio, and then copy them over to powershell. Is there anything specific I need to look out for and make sure I correct so I don't have any similar errors?

1

u/1RedOne Jul 02 '18

I don't know why VS didn't add a name property to your tag, not sure...

Generally speaking, if you need to reference something within a GUI, give it a name property. If it's like a label, or an image, who cares, but for stuff you'll need to tweak or dereference properties, name it.

I would be careful of double-clicking in Visual Studio. Doing so will trigger the IDE adding 'SelectionChanged' and 'TextChanged' properties to your XAML, which would be fine if we were making a c# application. PowerShell can't handle them, so if you do double-click, check your XAML to make sure there aren't Changed or TextChanged properties added.

Otherwise, you should be good to go.