Scripts Thread, Powershell WPF GUI modification in Coding and Web Development; Hi all
I have been playing around with Powershell and the .net framework Windows Presentation Foundation (WPF). Using powershell, i ...
2nd May 2011, 08:08 PM #1
- Rep Power
Powershell WPF GUI modification
I have been playing around with Powershell and the .net framework Windows Presentation Foundation (WPF). Using powershell, i can insert XAML code inside an object and execute this from within Powershell showing a GUI for users to interact with.
This is all working very well, and im having lost of fun playing with this (as shown by posting from home on a bank holiday monday lol), The only problem im having is when i try and edit the design of the form after the form has been generated.
I can change basic elements in the form (Height, Width e.c.t) by changing the desired variable and entering a new value, then passing the processing thread to the WPF generated window with a "regenerate" command. However i can not figure out how i can add extra generated content (i.e. extra text box or checkboxes) with this method, as there doesn't seem to be a method to add children / content to the canvas?
The only way i have found to get around this so far is to have my powershell code include a button on click even that closes the current open form, re-generates the XAML code for the window, and then show the form dialog again. This however only seems to work once, and im not sure how this would effect other options within the program.
Does anyone have a better method to dynamically add / remove UI elements with this?
Last edited by koryo; 2nd May 2011 at 10:27 PM.
IDG Tech News
3rd May 2011, 12:34 PM #2
Can't you use Canvas.Children.Add(whatever_control)?
This is how I'd approach the same thing in C# at least.
3rd May 2011, 08:27 PM #3
- Rep Power
Hi jamesb, thanks for your responce.
In responce to your help, i had a quick look at my form to try this. According to powershell there is no "add" method on the canvas children object. However i gave it a go anyway, and got a responce saying that powershell can not convert a string to the .net object that appears to be required. Looks like more fiddle pokery is required here...
thanks for the heads up on that hidden little method though.
3rd May 2011, 08:48 PM #4
Originally Posted by koryo
3rd May 2011, 09:04 PM #5
- Rep Power
Originally Posted by Arthur
Powerboots does sound very interesting, and somthing i will probably get into very soon. I was trying not to get into too many external modules for the time being as it would be nice to have cross-system code without having to distribute another module along side it.
4th May 2011, 11:31 AM #6
If it's saying it can't convert, you'll probably need to strongly cast the object you're adding.
and so forth.
By RabbieBurns in forum *nix
Last Post: 27th May 2010, 11:32 AM
By HodgeHi in forum Web Development
Last Post: 24th September 2007, 03:49 PM
By tosca925 in forum Windows
Last Post: 17th January 2006, 06:13 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)