I found this Powershell function code block to choose a folder. Then, I added two variables (sourcePath, source) to reference to a XAML file. When, user presses "OK", I need the selected folder path to be shown in a different list box,"$sourcePath". I tried calling the list box as " $sourcePath.Write($objForm.SelectedPath)" after the "Return $objForm.SelectedPath". I'm doing something wrong, but don't know how to fix it. Thank you.

```
$XAML = @'
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Choose Folder" Height="350" Width="500">
<StackPanel>      
<Button x:Name="choose" Content="choose" HorizontalAlignment="Left"  
Margin="42,108,0,0" VerticalAlignment="Top" Width="121" />
<ListBox x:Name="sourcePath" HorizontalAlignment="left" Height="45" 
Margin="42,120,0,0" VerticalAlignment="Top" Width="400"/> 
</StackPanel>
</Window>
'@

$sourcePath=$win.Find("sourcePath")
$source=$win.Find("source")
$source.Add_click({Select-FolderDialog})
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") |        
Out-Null
Function Select-FolderDialog 
{param([string]$Description="Select Folder",[string]$RootFolder="Desktop")   
 $objForm = New-Object System.Windows.Forms.FolderBrowserDialog
 $objForm.Rootfolder = $RootFolder
 $objForm.Description = $Description
 $Show = $objForm.ShowDialog()
    If ($Show -eq "OK")
    {
     Return $objForm.SelectedPath
     $sourcePath.Write($objForm.SelectedPath)
    }
    Else
    {
      Write-Error "Operation cancelled by user."
    }
    $b = Select-FolderDialog
}

```