You can pretty much lift all the original code. Microsoft tried to make the
WPF names match the WinForms names so this could be done.

There is no appendtext method on text boxes. I would simply do
$TextBox.Text = $TextBox.Text + "New text"

Bindings aren't really needed for text boxes and things like that. They are
required for DataGrids (though it could happen in the background without
you knowing) but I did a lot of work in WPF without doing any bindings.
Simply interact directly with the controls (like I did above for the text
box). Bindings greatly help the process along when you thread, but it's not
a big deal if you don't.

On Fri, Feb 26, 2016 at 1:11 AM Mote, Todd <[email protected]> wrote:

> Ok, Ok, So I installed VS Community, recreated my UI, and got it running
> from ISE.  What took about 1000 lines to build in Forms only took about 75
> lines in XAML.  You convinced me.
>
>
>
> I had an issue with the select node code, but after messing around with it
> I ended up taking “[@Name]” out since you’re getting the $_.name property
> in the foreach.  So mine works looking like this:
>
>
>
> $xaml.SelectNodes('//*') | Foreach-Object { Set-Variable -Name ('Window' +
> '_' + $_.Name) -Value $Window.FindName($_.Name) }
>
>
>
> Which is fine, it makes all the variables like I expect them to.  With the
> [@Name] in there it didn’t return any results.
>
>
>
> Got my “Cancel” button closing the form too, and populated some of my pull
> downs.  Now the real work begins…
>
>
>
> I can pretty much lift all the functions and actions for all the buttons
> and pulldown elements from my original code to this, changing the names of
> the variables of course, right?  Basically I can get it working the same
> way it’s working now, just with WPF instead of forms?
>
>
>
> With all the stuff I do, I have a text box for output when users select
> things in pull downs and click buttons, how do I append text to my output
> text box if it’s in the XAML?  Or is that the same too, I just do
> $window_textboxOutput.appendtext((“stuff”))?  It didn’t seem to work.
>
>
>
> I do want to runspace some things.  I pretty sure I will have to do the
> binding bit you talked about if I thread a button action that writes output
> to the output text box, right?
>
>
>
> Fantastic series of post too, thanks much for writing them.  I’m excitd to
> try threading stuff, but I should probably get a handle on WPF I guess
> first..
>
>
>
> Thanks Ryan, and if at any point this is too much for the list I’m happy
> to take it offlist if you have the time.
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Mote, Todd
> *Sent:* Thursday, February 25, 2016 7:19 PM
> *To:* [email protected]
> *Subject:* RE: [powershell] GUIs and runspaces
>
>
>
> Windows forms, by hand.  (I really need a copy of visual studio or
> powershell studio, or something..  J )
>
>
>
> Thanks so much guys.  I had totally forgotten about this list until I saw
> the error handling thread.  I’d found http://poshcode.org/5520 and got
> some of that to work, partly.  I’ll start looking through these in earnest,
> but it looks like exactly what I need.  my ui is pretty complicated and
> lots of elements do or don’t do things depending on data in other elements,
> so I’m not sure how it will go, but I’ll give it a try.
>
>
>
> Xaml looks somewhat simpler to write, but I’ll save that for another day.
> J
>
>
>
>
>
>
>
>
>
> *From:* [email protected] [
> mailto:[email protected] <[email protected]>] *On
> Behalf Of *Ryan
> *Sent:* Thursday, February 25, 2016 5:04 PM
> *To:* [email protected]
> *Subject:* Re: [powershell] GUIs and runspaces
>
>
>
> Is this WPF or Windows Forms?
>
>
>
> When I started writing WinForms, this blog post helped me learn about
> different runspaces and how to make the forms more responsive:
> https://www.sapien.com/blog/2012/05/16/powershell-studio-creating-responsive-forms/
>
>
>
> If you are doing it in WPF, I have a series of posts on UI development:
> http://www.ephingadmin.com/better-know-a-powershell-ui/
>
> The "Quack like a duck" post talks about different threads and uses
> PoshRSJob (3rd party cmdlet on GitHub) to do the threading.
>
>
>
> Boe Prox (the author of PoshRSJob) has a lot of good information on this
> also. Here's a post about writing data from one thread to another:
>
>
> http://learn-powershell.net/2012/10/14/powershell-and-wpf-writing-data-to-a-ui-from-a-different-runspace/
>
>
>
> Let me know if you need any other resources!
>
>
>
>
>
> On Thu, Feb 25, 2016 at 4:59 PM Mote, Todd <[email protected]>
> wrote:
>
> So I've written a fancy PowerShell script and given it a GUI and it works
> great.  As I add more features to it though, I find that it’s taking longer
> and longer to run and thought I would try to get it to run in a separate
> thread to free up the GUI.  I’m not finding many resources to help me learn
> how to do that. Can anybody point me to any?  I know about sunspaces, bur
> have not had any luck with getting them to work.  Help?
>
>
>
> Sent from my Windows 10 phone
>
>
>
>
> ================================================
> Did you know you can also post and find answers on PowerShell in the
> forums?
> http://www.myitforum.com/forums/default.asp?catApp=1
>
>
> ================================================
> Did you know you can also post and find answers on PowerShell in the
> forums?
> http://www.myitforum.com/forums/default.asp?catApp=1
>
>
> ================================================
> Did you know you can also post and find answers on PowerShell in the
> forums?
> http://www.myitforum.com/forums/default.asp?catApp=1
>
> ================================================
> Did you know you can also post and find answers on PowerShell in the
> forums?
> http://www.myitforum.com/forums/default.asp?catApp=1


================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

Reply via email to