testwpf2.ps1 972 B

123456789101112131415161718192021222324
  1. #XAML Code kann zwischen @" und "@ ersetzt werden:
  2. [xml]$XAML = @"
  3. <Window x:Class="WpfApplication.MainWindow"
  4. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  5. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  6. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  7. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  8. xmlns:local="clr-namespace:WpfApplication"
  9. mc:Ignorable="d"
  10. Title="MainWindow" Height="768" Width="1024">
  11. <StackPanel x:Name="StackPanel" Margin = "50,50,50,50">
  12. </StackPanel>
  13. </Window>
  14. "@ -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^<Win.*', '<Window' #-replace wird benötigt, wenn XAML aus Visual Studio kopiert wird.
  15. Function TestWPF(){
  16. #XAML laden
  17. [void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
  18. [Windows.Markup.XamlReader]::Load( (New-Object System.Xml.XmlNodeReader $XAML) )
  19. }