How would I go about getting these GUI variables into a hash table?

$xaml contains all the GUI info. I’d like this:

$xaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name "WPF$($.Name)" -Value $Form.FindName($.Name)} # WPFTextbox1 etc,

to fit in here $GUIhash = [hashtable]::Synchronized(@{})

So I can reference GUI objects from within a runspace. How would I go about this?

Post the full code.