WPF GUI for PowerShell Scripts

How can i run powershell scripts or multiple PS Commands from WPF? I am using this thing but getting some Method invocation Error.

using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Runspaces;

Creating runspace and calling that script. [I am calling an external script.]
another thing i tried is :

using (PowerShell PowerShellInstance = PowerShell.Create())

But from this i can run a single command.

One working method i found was using script below:

Add-Type -AssemblyName PresentationFramework
[xml]$xaml = 




Function Test-InternetConnection {
    DefaultParameterSetName = 'Site'
        Mandatory = $True,
        ParameterSetName = '',
        ValueFromPipeline = $True)]
        Mandatory = $True,
        ParameterSetName = '',
        ValueFromPipeline = $False)]
    #Clear the screen
    #Start testing the connection and continue until the connection is good.
    While (!(Test-Connection -computer $site -count 1 -quiet)) {
       # Write-Host -ForegroundColor Red -NoNewline "Connection down..."
        Write-Output "Connection down..."
        Start-Sleep -Seconds $wait
    #Connection is good
    #Write-host -ForegroundColor Green "$(Get-Date): Connection up!"
     Write-Output "$(Get-Date): Connection up!"
Function Servicereport()
$obj = Get-Process | Out-GridView
Start-Sleep 2

Function Processreport()
Test-InternetConnection -Site google.com -Wait 2
Start-Sleep 2

$reader=(New-Object System.Xml.XmlNodeReader $xaml)
$Window=[Windows.Markup.XamlReader]::Load( $reader )

$button1 = $Window.FindName("Services")
$button2 = $Window.FindName("Process")
$Window.ShowDialog() | Out-Null

But with this approach i am unable to get Modern UI.

Please help i am actually confused.

So, this isn’t “from WPF.” WPF is a presentation framework, not a language.

What language are you writing in?