Skip to content

Instantly share code, notes, and snippets.

@ChadSki
Created September 21, 2013 00:28
Show Gist options
  • Select an option

  • Save ChadSki/6645690 to your computer and use it in GitHub Desktop.

Select an option

Save ChadSki/6645690 to your computer and use it in GitHub Desktop.
WPF Wharrgarbl
<Window.Template>
<ControlTemplate TargetType="{x:Type Controls:MetroWindow}">
<Grid Background="{TemplateBinding Background}">
<AdornerDecorator>
<ContentControl IsTabStop="False" FocusVisualStyle="{x:Null}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="PART_TitleBar"
Height="{Binding TitlebarHeight, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}"
Visibility="{TemplateBinding ShowTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}" Background="{DynamicResource WindowTitleColorBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image
Visibility="{TemplateBinding ShowIconOnTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}"
Source="{TemplateBinding Icon}"
RenderOptions.EdgeMode="Aliased" RenderOptions.BitmapScalingMode="HighQuality"/>
<TextBlock
x:Name="WindowTitleTextBlock"
Grid.Column="1"
Text="{TemplateBinding Title}"
HorizontalAlignment="Left"
TextTrimming="CharacterEllipsis"
VerticalAlignment="Center"
Margin="8 -1 0 0"
FontSize="16"
FontFamily="{DynamicResource HeaderFontFamily}"
Foreground="{TemplateBinding TitleForeground}"/>
</Grid>
<ContentPresenter
Content="{Binding WindowCommands, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}"
x:Name="PART_WindowCommands"
Panel.ZIndex="1"
Grid.RowSpan="2"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Height="{Binding TitlebarHeight, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" />
<ContentPresenter Grid.Row="1"/>
<ItemsControl Grid.Row="0"
Grid.RowSpan="2"
Panel.ZIndex="2"
KeyboardNavigation.TabNavigation="None"
ItemsSource="{Binding Flyouts, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}"
VerticalAlignment="Stretch">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid TextElement.Foreground="{DynamicResource FlyoutWhiteBrush}" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
</ContentControl>
</AdornerDecorator>
<Border x:Name="PART_Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" IsTabStop="false" Visibility="Collapsed" VerticalAlignment="Bottom"/>
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
<Condition Property="WindowState" Value="Normal"/>
</MultiTrigger.Conditions>
<Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
</MultiTrigger>
<Trigger Property="TitleCaps" Value="True">
<Setter TargetName="WindowTitleTextBlock" Property="Text" Value="{Binding Path=Title, RelativeSource={RelativeSource TemplatedParent}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Window.Template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment