Using Update-WPFJob to add ListView items in StackPanel

Oct 31, 2011 at 1:15 PM
Hi,
 
I have the following code and i'm trying to add a value to the Logs listview using Update-WPFJob
 
 $Job = StackPanel -ControlName 'UpgradeBuild' -Tag 'UpgradeBuild'  {
    UniformGrid -Name UserInfo -Margin 5 -Columns 2 -Rows 5 {
        "UserAccount"
        TextBox -Name UserName -Margin 2
        "Password"
        TextBox -Name Password -Margin 2
        "Working Directory"
        TextBox -Name WorkDir -Margin 2 }
     New-ListView -Name 'Logs' -Tag 'Logs' -ItemsSource {
              New-Object System.Collections.ObjectModel.ObservableCollection[PSObject](,([PSObject[]](&{
              New-Object PSObject -Property @{ Status = "[Info]"; Message = "FormInitialized"}  }))) 
      	 }  -View {
         New-GridView -Columns {
                    New-GridViewColumn -Header "Status" -DisplayMember { Binding Status }
                    New-GridViewColumn -Header "Message" -DisplayMember { Binding Message }
              	} 
			}
 
} -asjob

I saw several examples on how to upgrade the parent using the component name ($Logs) or using the $Window variable however i haven't been able to get to the listview component ItemSource and update that as long as this is in a Stack Panel.
$Job | Update-WPFJob -Command { $Logs.ItemsSource.Add(( New-Object PSObject -Property @{ Status = "[ERROR]"; Message = "Working Directory was not created" } )) }

 

 

Do you have any idea on how to get this working and traverse the stack pannel parent and add the values to it's listview child?

 

Thanks,

Cosmin