dev4sys / metrohamburgermenu_v3 Goto Github PK
View Code? Open in Web Editor NEWMetro Hamburger Menu with Mahapps ver. 2.0
Metro Hamburger Menu with Mahapps ver. 2.0
Hello @dev4sys,
First of all I would like to say thank you for the awesome work you're doing!
I've been looking around a lot to help me build a WPF GUI for my PowerShell script, and found your blog posts the most helpfull.
That being said, you have to know I'm completely new to WPF so sorry for any stupid questions I'm asking.
I'm trying to combine the DataGrid used in your PsCustomDialog (https://github.com/dev4sys/PsCustomDialog) with this HamburgerMenu and show the DNS records in our domain.
What I have done to get this working is I replaced the code from views\Home.xaml with below code:
<Grid
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\resources\Icons.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Grid.Resources>
<Grid>
<StackPanel HorizontalAlignment="Center">
<!-- CONTAINER -->
<StackPanel Margin="10,10,10,10" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Vertical">
<DataGrid x:Name="DNSGrid" AutoGenerateColumns="False" Margin="33,0,0,0"
GridLinesVisibility="All" HorizontalGridLinesBrush="#FFD4D4D4" VerticalGridLinesBrush="#FFD4D4D4"
OverridesDefaultStyle="True" CanUserAddRows="False">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding DNSName}" Header="Name" IsReadOnly="True" Width="auto"/>
<DataGridTextColumn Binding="{Binding DNSType}" Header="Type" IsReadOnly="True" Width="auto"/>
<DataGridTextColumn Binding="{Binding DNSData}" Header="Data" IsReadOnly="True" Width="auto"/>
<DataGridTextColumn Binding="{Binding DNSTimestamp}" Header="Timestamp" IsReadOnly="True" Width="auto"/>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button x:Name="View" Background="#FF44AFE3" Style="{DynamicResource MetroCircleButtonStyle}"
Height="28" Width="28" Cursor="Hand" HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch" HorizontalAlignment="Center" VerticalAlignment="Center"
BorderThickness="0" Margin="0,0,0,0">
<Rectangle Width="10" Height="10" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="white">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_magnify}"/>
</Rectangle.OpacityMask>
</Rectangle>
</Button>
<Button x:Name="Edit" Background="#198C19" Style="{DynamicResource MetroCircleButtonStyle}"
Height="28" Width="28" Cursor="Hand" HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch" HorizontalAlignment="Center" VerticalAlignment="Center"
BorderThickness="0" Margin="0,0,0,0">
<Rectangle Width="10" Height="10" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="white">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_edit}"/>
</Rectangle.OpacityMask>
</Rectangle>
</Button>
<Button x:Name="Delete" Background="#FFA500" Style="{DynamicResource MetroCircleButtonStyle}"
Height="28" Width="28" Cursor="Hand" HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch" HorizontalAlignment="Center" VerticalAlignment="Center"
BorderThickness="0" Margin="0,0,0,0">
<Rectangle Width="10" Height="10" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="white" >
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_close}"/>
</Rectangle.OpacityMask>
</Rectangle>
</Button>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</StackPanel>
</Grid>
</Grid>
The PowerShell command I'm using to get the DNS info is:
$DNSData = Get-DnsServerResourceRecord -ComputerName HOSTNAME -ZoneName domain.com | Select-Object Hostname,RecordType,Timestamp,RecordData
In my Main.ps1 I have below code:
$DNSGrid = $HomeXaml.FindName("DNSGrid") | Out-Null
$Script:observableCollection = [System.Collections.ObjectModel.ObservableCollection[Object]]::new()
foreach ( $DNSRecord IN $DNSData ) {
$objArray = New-Object PSObject
$objArray | Add-Member -type NoteProperty -name DNSName -value $DNSRecord.Hostname
$objArray | Add-Member -type NoteProperty -name DNSType -value $DNSRecord.RecordType
$objArray | Add-Member -type NoteProperty -name DNSData -value $DNSRecord.RecordData
$objArray | Add-Member -type NoteProperty -name DNSTimestamp -value $DNSRecord.Timestamp
$Script:observableCollection.Add($objArray) | Out-Null
}
# Add data to the datagrid
$DNSGrid.ItemsSource = $Script:observableCollection
(You see $DNSGrid = $HomeXaml.FindName("DNSGrid") | Out-Null in the first line, when I remove | Out-Null from that line I see a lot of text in my PS window and PS then crashes (going to fast to see what is being thrown in the PS window))
But when I start the script, I get below error in my PS window:
The property 'ItemsSource' cannot be found on this object. Verify that the property exists and can be set.
At C:\PATH_TO_SCRIPT\Scripts\GUI Scripts\DNSManager\Main.ps1:190 char:1
+ $DNSGrid.ItemsSource = $Script:observableCollection
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
When I replace my foreach with your sample code like below, I'm getting the same error.
$objArray = New-Object PSObject
$objArray | Add-Member -type NoteProperty -name ComputerName -value "Computer_03"
$objArray | Add-Member -type NoteProperty -name IP_Adress -value "192.168.0.0"
$objArray | Add-Member -type NoteProperty -name Domain -value "Domain0"
$objArray | Add-Member -type NoteProperty -name Patch -value $true
$script:observableCollection.Add($objArray) | Out-Null
Do you have any idea what I'm doing wrong here?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.