Product: PowerShell Universal
Version: 4.1.4
Hello everybody!
I’m having some issues with Set-UDElement
I have a class with a method called SetContent
that updates the content
attribute of the class as well as the content displayed in a text box:
[void] SetContent ([string] $Content) {
$this.Content = $Content
Set-UDElement -Id $this.GetID() -Properties @{ Value = $this.Content }
}
However, when I call the method like this:
$SearchByName.SetIcon("skull-crossbones") # Other code
$SearchByName.SetContent("Hello :)") # <--- Here
$SearchByName.GetID() # Other code
the Set-UDElement doesn’t work. The content
attribute is updated just fine, but the value inside the textbox doesn’r change.
I tried using a button to update the value shown:
New-UDButton -OnClick {
$SearchByName.SetContent((Get-Date -Format "o"))
}
And it worked just fine.
The textbox looks like this:
New-UDTextbox -Id $SearchByName.GetID() -Label $SearchByName.GetName() -Icon (New-UDIcon -Icon $SearchByName.GetIcon()) -HelperText $SearchByName.GetHelper() -OnChange {
$SearchByName.SetContent($EventData);
} -FullWidth
Am I doing something wrong? I don’t understand why it’s not working
(Also the SetIcon()
method works just fine, even without a button)