ProgressBar not running with

Welcome Forums General PowerShell Q&A ProgressBar not running with

This topic contains 2 replies, has 2 voices, and was last updated by

6 months, 2 weeks ago.

  • Author
  • #111125

    Points: 0
    Rank: Member

    Hi everyone,

    I've been Googling a lot and ain't able to make this work.

    Essentially, I'm designing a WPF form with a progress bar while I run som lenghty stuff behind.
    While this may seem rather easy and basic, I am no coder just a very resourceful guy.

    My problem is when I use $window.ShowDialog(), the animation works perfectly but of course doesn't run anything because it's a modal form. Of course I went with $window.Show() which does bring up the WPF form and runs my stuff but the progressbar animation ain't working. I tried with "runspace" and my latest test is with "start-job".

    As you will see, I'm not doing much in my code, it's a "proof of concept". I will be adding this to a way bigger PS1 file once it'll be working.

    Thanks for any help you can give me.

    Here is my code for the PS1 file.

    Add-Type -AssemblyName PresentationFramework
    function Load-Xaml {
    	[xml]$xaml = Get-Content -Path $PSScriptRoot\ProgressBar1.xaml
    	$manager = New-Object System.Xml.XmlNamespaceManager -ArgumentList $xaml.NameTable
    	$manager.AddNamespace("x", "");
    	$xamlReader = New-Object System.Xml.XmlNodeReader $xaml
    $ScriptBlock = {
    	sleep 10
    $window = Load-Xaml
    #$window.Add_Closing( { $_.Cancel = $true; } ) 
    $Worker = Start-Job -scriptblock $ScriptBlock
    Do {
    	#I added these lines to be sure something is actually going on
    	Write-Host "." -NoNewline
    	Start-Sleep -Seconds 1
    } While ( $Worker.state -notlike "Completed" )

    Here is my XALM code, which again is very basic

  • #111238

    Points: 1,634
    Helping Hand
    Rank: Community Hero

    Your XAML code is not visible, post it via gist and add gist the link to the post.

  • #111449

    Points: 0
    Rank: Member

    I've removed the leading "< " so I can post this correctly. Please assume those are there.

    Title="ProgressBar" Height="100" Width="300" ResizeMode="NoResize" HorizontalAlignment="Center" VerticalAlignment="Center" WindowStartupLocation="CenterScreen" Topmost="True" WindowStyle="ToolWindow" ScrollViewer.VerticalScrollBarVisibility="Disabled" IsHitTestVisible="False">

    Grid Margin="20">
    ProgressBar Name="pbStatus" IsIndeterminate="True" />

The topic ‘ProgressBar not running with’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort