UI inconsistency with PSScriptPad app preview and running script

Hello,

I have noticed an inconsistency with the way the interface looks between the preview in PSScriptPad and when I run the script. See image below. The window in front (with the purple header) is the script being run. The window behind (with the cyan header) is the preview from PSScriptPad.

It’s a lot harder to plan if I need to run the script every time I want to see how it looks. :disappointed_relieved:

Is it possible I have a missing prerequisite?
Am I doing something wrong?

Here are the two relevant files that I run to replicate the issue:

main.ps1

[System.Reflection.Assembly]::LoadWithPartialName("PresentationFramework") | Out-Null
function Import-Xaml {
    [xml]$Xaml = Get-Content -Path $PSScriptRoot\main.xaml
    $Manager = New-Object System.Xml.XmlNamespaceManager -ArgumentList $Xaml.NameTable
    $Manager.AddNamespace("x", "http://schemas.microsoft.com/winfx/2006/xaml");
    $XamlReader = New-Object System.Xml.XmlNodeReader $Xaml
    [Windows.Markup.XamlReader]::Load($XamlReader)
}
$Window = Import-Xaml
$Window.ShowDialog() | Out-Null

main.xaml

<Window x:Name="main"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        Width="900"
        Height="600"
        Background="White"
        Title="ProofOfConceptStuff">
  <Grid>
    <TabControl x:Name="MainTabCtrl"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                Grid.Column="0"
                Grid.Row="0">
      <TabItem Margin="8,8,-2,-8"
               Header="TabItem0">
        <Grid Margin="3,3,3,30" VerticalAlignment="Stretch" />
      </TabItem>
      <TabItem Margin="8,8,-2,-8"
               Header="AnotherTab">
        <Grid />
      </TabItem>
      <TabItem Margin="8,8,-2,-8"
               Header="TabpqMW">
        <Grid />
      </TabItem>
      <TabItem Margin="8,8,-2,-8"
               Header="ThisTabHasALongName">
        <Grid />
      </TabItem>
      <TabItem Margin="8,8,-2,-8"
               Header="A0">
        <Grid />
      </TabItem>
      <TabItem Margin="8,8,-2,-8"
               Header="A1">
        <Grid />
      </TabItem>
      <TabItem Margin="8,8,-2,-8"
               Header="A2">
        <Grid />
      </TabItem>
      <TabItem Margin="8,8,-2,-8"
               Header="A3">
        <Grid />
      </TabItem>
    </TabControl>
  </Grid>
</Window>

Also, here is package.psd1

@{
    Root = 'c:\Users\Samuel\Documents\GitLab\ncpa-helper\main.ps1'
    OutputPath = 'c:\Users\Samuel\Documents\GitLab\ncpa-helper\out'
    Package = @{
        Enabled = $true
        Obfuscate = $false
        HideConsoleWindow = $false
        DotNetVersion = 'net6.0'
        PowerShellVersion = "7.2.0"
        FileVersion = '1.0.0'
        FileDescription = ''
        ProductName = ''
        ProductVersion = ''
        Copyright = ''
        RequireElevation = $true
        ApplicationIconPath = ''
        PackageType = 'Console'
    }
    Bundle = @{
        Enabled = $true
        Modules = $true
        # IgnoredModules = @()
    }
}

Thank you!

~ Sam

That’s drastically different!

Are you using a custom UI library in PSScriptPad like MahApps?

Sorry, but I don’t know. If I am, I’m unaware of it. :sweat_smile:

Can you please explain how I can check / manage the UI library?

If it can help, I am using Visual Studio Code, and the plugin PowerShell Pro Tools. My OS is Windows 11 Pro.

If you didn’t add one specifically then you shouldn’t be using one so don’t worry too much about it! @DataTraveler, can you try to recreate this?

@adam after reproducing the issue I raised #1409 on the tracker

image