Skip to content

Instantly share code, notes, and snippets.

@theznerd
Created February 20, 2019 05:26
Show Gist options
  • Save theznerd/fe929c59bef4ca129d763cd34791b8cf to your computer and use it in GitHub Desktop.
Save theznerd/fe929c59bef4ca129d763cd34791b8cf to your computer and use it in GitHub Desktop.
#### You need the following DLLs from the MahApps.Metro NuGet Package
#### Put them all in the root folder the script is run from
# ControlzEx.dll
# MahApps.Metro.dll
# System.Windows.Interactivity.dll
## Load The Assemblies/DLLs
Add-Type -assemblyName PresentationFramework
Add-Type -assemblyName PresentationCore
Add-Type -assemblyName WindowsBase
$mahapps = Get-ChildItem "$PSScriptRoot\*.dll"
foreach($dll in $mahapps)
{
[System.Reflection.Assembly]::LoadFrom("$($dll.FullName)") | out-null
}
[xml]$xaml = @"
<Controls:MetroWindow
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:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<!-- Accent and AppTheme setting -->
<!--"Red", "Green", "Blue", "Purple", "Orange", "Lime", "Emerald", "Teal", "Cyan", "Cobalt", "Indigo", "Violet", "Pink", "Magenta", "Crimson", "Amber", "Yellow", "Brown", "Olive", "Steel", "Mauve", "Taupe", "Sienna" -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Yellow.xaml" />
<!-- "BaseLight", "BaseDark" -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.Resources>
<!-- this is the template for the items (options too) -->
<DataTemplate x:Key="MenuItemTemplate" DataType="{x:Type Controls:HamburgerMenuIconItem}">
<Grid x:Name="RootGrid"
Height="48"
Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
FontSize="28"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="Wingdings"
Foreground="White"
Text="{Binding Glyph}" />
<TextBlock Grid.Column="1"
VerticalAlignment="Center"
FontSize="16"
Text="{Binding Label}" />
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:HamburgerMenu}}, Path=IsPaneOpen}" Value="False">
<Setter TargetName="RootGrid" Property="ToolTip" Value="{Binding ToolTip, Mode=OneWay}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</Grid.Resources>
<Controls:HamburgerMenu
DisplayMode="CompactInline"
ItemTemplate="{StaticResource MenuItemTemplate}">
<Controls:HamburgerMenu.ItemsSource>
<Controls:HamburgerMenuItemCollection>
<Controls:HamburgerMenuGlyphItem Glyph='-' Label="You've Got Mail!" />
<Controls:HamburgerMenuGlyphItem Glyph='C' Label="Thumbs Up" />
<Controls:HamburgerMenuGlyphItem Glyph='D' Label="Thumbs Down" />
</Controls:HamburgerMenuItemCollection>
</Controls:HamburgerMenu.ItemsSource>
</Controls:HamburgerMenu>
</Grid>
</Controls:MetroWindow>
"@
#Read the form
$Reader = (New-Object System.Xml.XmlNodeReader $xaml)
$Form = [Windows.Markup.XamlReader]::Load($reader)
[void]$Form.ShowDialog()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment