I'm pretty new on powershell and noob on GUI. I try to make a GUI working with powershell Windows 7 with powershell V2
Here is my xaml code
<Window x:Class="WpfApplication1.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:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="558.138" Width="474.668">
<Grid Margin="0,0,0,46">
<Grid.RowDefinitions>
<RowDefinition Height="335*"/>
<RowDefinition Height="37*"/>
<RowDefinition Height="38*"/>
<RowDefinition Height="12*"/>
</Grid.RowDefinitions>
<CheckBox x:Name="checkBox" Content="Adobe READER" HorizontalAlignment="Left" Margin="6,215,0,0" VerticalAlignment="Top" Checked="checkBox_Checked"/>
<Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="98" Margin="6,10,0,0" VerticalAlignment="Top" Width="454">
<Image x:Name="logo_europe_jpg" Margin="177,0,0,9" Source="logo_europe.jpg" Stretch="Fill"/>
</Border>
<CheckBox x:Name="checkBox_Copy" Content="PDF Creator" HorizontalAlignment="Left" Margin="6,236,0,0" VerticalAlignment="Top" Checked="checkBox_Checked"/>
<CheckBox x:Name="checkBox_Copy1" Content="VPN Client" HorizontalAlignment="Left" Margin="6,306,0,0" VerticalAlignment="Top" Checked="checkBox_Checked" RenderTransformOrigin="0.504,3.382"/>
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="10,18,0,0" TextWrapping="Wrap" Text="EUROPE TECHNOLOGIES STORE" VerticalAlignment="Top" Width="310"/>
<CheckBox x:Name="checkBox_Copy2" Content="WinSCP" HorizontalAlignment="Left" Margin="6,285,0,0" VerticalAlignment="Top" Checked="checkBox_Checked" RenderTransformOrigin="0.504,3.382"/>
<CheckBox x:Name="checkBox_Copy3" Content="Google Chrome" HorizontalAlignment="Left" Margin="6,172,0,0" VerticalAlignment="Top" Checked="checkBox_Checked" RenderTransformOrigin="0.504,3.382"/>
<CheckBox x:Name="checkBox_Copy4" Content="Mozilla Firefox" HorizontalAlignment="Left" Margin="6,151,0,0" VerticalAlignment="Top" Checked="checkBox_Checked" RenderTransformOrigin="0.504,3.382"/>
<Button x:Name="button" Content="OK" HorizontalAlignment="Left" Margin="115,12,0,-22" Grid.Row="3" VerticalAlignment="Top" Width="75" Click="button_Click"/>
<TextBlock x:Name="textBlock1" HorizontalAlignment="Left" Margin="42,113,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="404"><Run Text="Sélectionn"/><Run Text="ez"/><Run Text=" "/><Run Text="les applications à installer et appuyez sur OK"/></TextBlock>
<Button x:Name="button1" Content="Annuler" HorizontalAlignment="Left" Margin="263,12,0,-22" Grid.Row="3" VerticalAlignment="Top" Width="75" Height="22"/>
<TextBox x:Name="textBox" HorizontalAlignment="Left" Height="23" Margin="10,0,0,0" TextWrapping="Wrap" Text="Suggestion de programmes" VerticalAlignment="Top" Width="278" Grid.Row="2"/>
<Button x:Name="button2" Content="Envoyer" HorizontalAlignment="Left" Margin="311,1,0,0" VerticalAlignment="Top" Width="75" Grid.Row="2"/>
</Grid>
</Window>
i changed x:name by name i deleted x:Class="WpfApplication1.MainWindow"
here's the error
Exception lors de l'appel de « Load » avec « 1 » argument(s) : « XmlNamespace, Assembly ou ClrNamespace absent de l'ins
truction Mapping. Ligne '0' position '0'. »
Au niveau de \STORE\EUROPE_ALEX_STORE.ps1 : 43 Caractère : 40
+ $Form=[Windows.Markup.XamlReader]::Load <<<< ($reader)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Vous ne pouvez pas appeler de méthode sur une expression ayant la valeur Null.
Au niveau de \STORE\EUROPE_ALEX_STORE.ps1 : 46 Caractère : 17
+ $Form.ShowDialog <<<< () | out-null
+ CategoryInfo : InvalidOperation: (ShowDialog:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
i deleted four lines: xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
Another error :
Exception lors de l'appel de « Load » avec « 1 » argument(s) : « Compilation obligatoire du fichier XAML qui spécifie l
es événements. Ligne '0' position '0'. »
Au niveau de \STORE\EUROPE_ALEX_STORE.ps1 : 39 Caractère : 40
+ $Form=[Windows.Markup.XamlReader]::Load <<<< ($reader)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Vous ne pouvez pas appeler de méthode sur une expression ayant la valeur Null.
Au niveau de \STORE\EUROPE_ALEX_STORE.ps1 : 42 Caractère : 17
+ $Form.ShowDialog <<<< () | out-null
+ CategoryInfo : InvalidOperation: (ShowDialog:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
there are no events on my buttons, i just want to display my form first.
here is the entire powershell script
Add-Type -AssemblyName presentationframework
Add-Type -AssemblyName PresentationCore
Add-Type -AssemblyName WindowsBase
[xml]$xaml = @’
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="EUROPE STORE" Height="560" Width="480">
<Grid Margin="0,0,0,46">
<Grid.RowDefinitions>
<RowDefinition Height="335*"/>
<RowDefinition Height="37*"/>
<RowDefinition Height="38*"/>
<RowDefinition Height="12*"/>
</Grid.RowDefinitions>
<CheckBox Name="checkBox" Content="Adobe READER" HorizontalAlignment="Left" Margin="6,215,0,0" VerticalAlignment="Top" Checked="checkBox_Checked"/>
<Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="98" Margin="6,10,0,0" VerticalAlignment="Top" Width="454">
<Image Name="logo_europe_jpg" Margin="177,0,0,9" Source="logo_europe.jpg" Stretch="Fill"/>
</Border>
<CheckBox Name="checkBox_Copy" Content="PDF Creator" HorizontalAlignment="Left" Margin="6,236,0,0" VerticalAlignment="Top" Checked="checkBox_Checked"/>
<CheckBox Name="checkBox_Copy1" Content="VPN Client" HorizontalAlignment="Left" Margin="6,306,0,0" VerticalAlignment="Top" Checked="checkBox_Checked" RenderTransformOrigin="0.504,3.382"/>
<TextBlock Name="textBlock" HorizontalAlignment="Left" Margin="10,18,0,0" TextWrapping="Wrap" Text="EUROPE TECHNOLOGIES STORE" VerticalAlignment="Top" Width="310"/>
<CheckBox Name="checkBox_Copy2" Content="WinSCP" HorizontalAlignment="Left" Margin="6,285,0,0" VerticalAlignment="Top" Checked="checkBox_Checked" RenderTransformOrigin="0.504,3.382"/>
<CheckBox Name="checkBox_Copy3" Content="Google Chrome" HorizontalAlignment="Left" Margin="6,172,0,0" VerticalAlignment="Top" Checked="checkBox_Checked" RenderTransformOrigin="0.504,3.382"/>
<CheckBox Name="checkBox_Copy4" Content="Mozilla Firefox" HorizontalAlignment="Left" Margin="6,151,0,0" VerticalAlignment="Top" Checked="checkBox_Checked" RenderTransformOrigin="0.504,3.382"/>
<Button Name="button" Content="OK" HorizontalAlignment="Left" Margin="115,12,0,-22" Grid.Row="3" VerticalAlignment="Top" Width="75" Click="button_Click"/>
<TextBlock Name="textBlock1" HorizontalAlignment="Left" Margin="42,113,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="404"><Run Text="Sélectionn"/><Run Text="ez"/><Run Text=" "/><Run Text="les applications à installer et appuyez sur OK"/></TextBlock>
<Button Name="button1" Content="Annuler" HorizontalAlignment="Left" Margin="263,12,0,-22" Grid.Row="3" VerticalAlignment="Top" Width="75" Height="22"/>
<TextBox Name="textBox" HorizontalAlignment="Left" Height="23" Margin="10,0,0,0" TextWrapping="Wrap" Text="Suggestion de programmes" VerticalAlignment="Top" Width="278" Grid.Row="2"/>
<Button Name="button2" Content="Envoyer" HorizontalAlignment="Left" Margin="311,1,0,0" VerticalAlignment="Top" Width="75" Grid.Row="2"/>
</Grid>
</Window>
'@
#Read XAML
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
$Form=[Windows.Markup.XamlReader]::Load( $reader )
#Show Form
$Form.ShowDialog() | out-null
# SIG # Begin signature block