powershell read xaml file code example
Example: powershell read xaml file
$currentDir = Split-Path $myInvocation.MyCommand.Path
$mainWindow = [IO.File]::ReadAllText($currentDir + "\..\wpf\ImageShrinker\MainWindow.xaml")
[xml]$XAML = $mainWindow -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^<Win.*', '<Window'
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
try{
$window=[Windows.Markup.XamlReader]::Load( (New-Object System.Xml.XmlNodeReader $XAML) )
} catch {
Write-Host "Windows.Markup.XamlReader konnte nicht geladen werden. Mögliche Ursache: ungültige Syntax oder fehlendes .net"
}