PowerShell_XAML icon indicating copy to clipboard operation
PowerShell_XAML copied to clipboard

Script Chokes on <Window.Resources> ControlTemplate Copy

Open futuremotiondev opened this issue 4 years ago • 0 comments

Hi there!

This script is a serious time saver.

I can get it to work, but it seems to choke on some more complex XAML. I've attached the failing XAML document to this post. (It's a zip file because Github doesn't allow me to upload XAML)

MainWindow.zip

The error:

12-04 02:42:42 D:\Dev\Powershell> d:\Dev\Powershell\Scripts\PowerShell_XAML\Snippet.ps1
WARNING: Unable to parse XML, with error: Exception calling "Load" with "1" argument(s): "Cannot create unknown type '{http://schemas.microsoft.coas.microsoft.com/winfx/2006/xaml/presentation}Null'."
 Ensure that there are NO SelectionChanged or TextChanged properties in your textboxes (PowerShell cannot process them)
ParentContainsErrorRecordException: D:\Dev\Powershell\Scripts\PowerShell_XAML\Snippet.ps1:334:5
Line |
 334 |      $Form=[Windows.Markup.XamlReader]::Load( $reader )
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "Load" with "1" argument(s): "Cannot create unknown type
     | '{http://schemas.microsoft.com/winfx/2006/xaml/presentation}Null'."

I think the reason is that the parser can't handle the <Window.Resources> content. I created this block so I could customize my comboboxes a bit more, but I have a feeling the code won't be parsable for PowerShell.

If there is any way you can take a look, that would be super helpful.

Thanks for the awesome script!

futuremotiondev avatar Dec 04 '21 09:12 futuremotiondev