Add-Type -AssemblyName PresentationFramework # Define data items in Json $list = @' [ { "Name": "John Doe", "Age": "30" }, { "Name": "Jane Smith", "Age": "25" }, { "Name": "Bob Johnson", "Age": "40" } ] '@ # Create sample data $people = $list | ConvertFrom-Json # Create XAML markup for the WPF application $xaml = @" "@ # Create a WPF XML reader and load the XAML markup $reader = [System.Xml.XmlReader]::Create([System.IO.StringReader] $xaml) $window = [Windows.Markup.XamlReader]::Load($reader) # Set the data context for the DataGrid $dataContext = $window.FindName('DataGrid') $dataContext.ItemsSource = $people # Show the window $window.ShowDialog() | Out-Null <# Add-Type -AssemblyName PresentationFramework # Define a class for the data items class Person { [string]$Name [int]$Age Person([string]$name, [int]$age) { $this.Name = $name $this.Age = $age } } # Create sample data $people = @( [Person]::new('John Doe', 30), [Person]::new('Jane Smith', 25), [Person]::new('Bob Johnson', 40) ) # Create a data source (ObservableCollection of PSObjects) #$people = New-Object System.Collections.ObjectModel.ObservableCollection[PSObject] # Add data to the data source #$people.Add([PSCustomObject]@{ Name = "John Doe"; Age = 30 }) #$people.Add([PSCustomObject]@{ Name = "Jane Smith"; Age = 25 }) # Create XAML markup for the WPF application $xaml = @" "@ # Create a WPF XML reader and load the XAML markup $reader = [System.Xml.XmlReader]::Create([System.IO.StringReader] $xaml) $window = [Windows.Markup.XamlReader]::Load($reader) # Set the data context for the DataGrid $dataContext = $window.FindName('DataGrid') $dataContext.ItemsSource = $people # Show the window $window.ShowDialog() | Out-Null #>