Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
- [void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
- #Region Build the MAINWindow
- [xml]$xamlMain = @"
- <Window
- 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:sys="clr-namespace:System;assembly=mscorlib"
- xmlns:local="clr-namespace:WW_Import"
- xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2"
- x:Name="Window" Title="MainWindow" Height="350" Width="525">
- <Grid>
- <Button x:Name="btnTest" Content="Button" HorizontalAlignment="Left" Margin="202,223,0,0" VerticalAlignment="Top" Width="75"/>
- <ListBox x:Name="listBox" HorizontalAlignment="Left" Height="105" Margin="30,40,0,0" VerticalAlignment="Top" Width="429">
- <ListBox.ItemTemplate>
- <DataTemplate>
- <Grid Margin="0,2">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="190" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <Button x:Name="btnRemoveOSCollEntry" Content="X"/>
- <TextBlock Margin="10,0,0,0" Grid.Column="2" Text="{Binding Title}" />
- </Grid>
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
- <Label x:Name="label" Content="Label" HorizontalAlignment="Left" Margin="147,164,0,0" VerticalAlignment="Top" Width="247"/>
- </Grid>
- </Window>
- "@
- #endregion
- $global:CurrentLocation = Get-Location
- function SetMainWindow($Picture, $HeaderText, $Text)
- {
- #region Controls
- $tMain = $WindowMain.FindName("tMain")
- $tHeader = $WindowMain.FindName("tHeader")
- $iMain = $WindowMain.FindName("iMain")
- $MainBorder = $WindowMain.FindName("MainBorder")
- #endregion
- $WindowMain.FindName("MainBackground").Background = "#FF076A80"
- $ScreenRes = [System.Windows.SystemParameters]::PrimaryScreenWidth
- if ($ScreenRes)
- {
- $WindowMain.Left = $Screenres - $WindowMain.Width
- }
- }
- $readerMain = (New-Object System.Xml.XmlNodeReader $xamlMain)
- $WindowMain = [Windows.Markup.XamlReader]::Load($readerMain)
- #region Controls
- $btnTest = $WindowMain.FindName("btnTest")
- $listBox = $WindowMain.FindName("listBox")
- $label = $WindowMain.FindName("label")
- #endregion
- $WindowMain.FindName("btnTest").Add_click({
- $label.Content = "Normal button clicked"
- })
- $WindowMain.FindName("btnRemoveOSCollEntry").Add_click({
- $label.Content = "DataTemplate button clicked"
- })
- $DataSource = @()
- $obj = New-Object PSCustomObject
- $obj | Add-Member -MemberType 'NoteProperty' -Name Title -Value "Test title"
- $DataSource += $obj
- $listBox.ItemsSource = $DataSource
- $WindowMain.ShowDialog() | Out-Null
- Exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement