I am using the code below to write a script that calls a WPF form. i would like to have the form being updated during code execution but whatever i try the code keeps running and only update the form afther execution.
so basically i need to run code:
update the forum with these settings and than start the following code.
anybody have an idea?
Add-Type-AssemblyNamePresentationCore,PresentationFramework,WindowsBase,system.windows.forms
#load validation form
[xml]$Global:xmlval=Get-Content-Path"$localdeploypath\scripts\dagform\validationform.xaml"
#correct source path for images
$xmlval.window.innerXml =$xmlval.window.innerXml.Replace('Source="','Source="'+$localdeploypath+'\scripts\dagform\')
#Create the XAML reader using a new XML node reader
$Global:xamvalGUI=[Windows.Markup.XamlReader]::Load((new-objectSystem.Xml.XmlNodeReader$xmlval))
#Create hooks to each named object in the XAML
$xmlval.SelectNodes("//*[@Name]") |%{
Set-Variable-Name ($_.Name) -Value$xamvalGUI.FindName($_.Name) -ScopeGlobal
}
#endregion load validation form
#region Buttons
$createdag.add_Click({
$xamvalGUI.close()
})
#endregion Buttons
#region events
$xamvalGUI.add_Loaded({
$errorbox2.Visibility ="visible"
$errorbox2.text ="start"
$global:xamvalGUI.Updatelayout()
start-sleep-seconds10
$errorbox2.text ="mid"
$global:xamvalGUI.Updatelayout()
start-sleep-seconds10
$errorbox2.text ="end"
})
$xamvalGUI.add_sourceinitialized({
#create timer object
$Global:timer=new-objectSystem.Windows.Threading.DispatcherTimer
$timer.interval =[timespan]"0:0:0.1"
#add event per tick
$timer.add_tick({
$global:xamvalGUI.Updatelayout()
write-host"form updated"
})
#start timer
$timer.start()
})
#endregion events
$xamvalGUI.ShowDialog()
$errorbox2.Visibility ="visible"
$errorbox2.text ="start"