Skip to content

Instantly share code, notes, and snippets.

@TScalzott
Created September 24, 2015 19:15
Show Gist options
  • Save TScalzott/4c474c660c73b3712042 to your computer and use it in GitHub Desktop.
Save TScalzott/4c474c660c73b3712042 to your computer and use it in GitHub Desktop.
# Our XAML for the WPF-based GUI.
$inputXAML = @"
<Window x:Name="Pick_Console" x:Class="LetUsWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LetUsWPF"
mc:Ignorable="d"
Title="MainWindow" Height="275" Width="410">
<Grid>
<Label x:Name="label_cluster" Content="Cluster:" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="cluster" HorizontalAlignment="Left" Margin="30,26,0,0" VerticalAlignment="Top" Width="342"/>
<Label x:Name="label_details" Content="VM Details:" HorizontalAlignment="Left" Margin="10,64,0,0" VerticalAlignment="Top"/>
<Button x:Name="console" Content="Console" HorizontalAlignment="Left" Margin="157,203,0,0" VerticalAlignment="Top" Width="75"/>
<DataGrid x:Name="details" HorizontalAlignment="Left" Margin="30,90,0,0" VerticalAlignment="Top" Height="92" Width="342" AlternationCount="1" IsReadOnly="True" SelectionMode="Single"/>
</Grid>
</Window>
"@
# Munge to remove what PowerShell doesn't like and cast as XML
# Remove design-time ignorable tags
# Convert "x:Name" nodes to "Name"
# Remove Window classing
[xml]$xaml = $inputXAML -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^<Win.*', '<Window'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment