Reputation: 21
I want to have CleanWindow on the Title, I'm new in WPF so i really struggle in this
Here's the code for MainWindow.xaml:
<Controls:MetroWindow x:Class="Twitch_Notifier.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Twitch_Notifier"
mc:Ignorable="d"
TitleCaps="False"
ShowTitleBar="True"
ShowIconOnTitleBar="False"
ResizeMode="CanMinimize"
Title="Twitch Notifier" Height="350" Width="525" WindowStartupLocation="CenterScreen"
GlowBrush="{DynamicResource AccentColorBrush}"
Style="{DynamicResource CleanWindowStyleKey}">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Resources/Icons.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Controls:MetroWindow.RightWindowCommands>
<Controls:WindowCommands>
<Button Content="settings" />
</Controls:WindowCommands>
</Controls:MetroWindow.RightWindowCommands>
<Grid>
</Grid>
Code for App.xaml:
<Application x:Class="Twitch_Notifier.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Twitch_Notifier"
StartupUri="MainWindow.xaml">
<Application.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 -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Clean/Clean.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
How can i fix this? Thanks for your help
Upvotes: 2
Views: 1109
Reputation: 11221
It's a limitation of the designer but the workaround is simple:
1) Cast the Window-style to a MetroWindow-style in Resources (MyCleanWindowStyle)
2) Apply the MetroWindow Style instead
<Controls:MetroWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Views;assembly=gasby.Wpf"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
ShowTitleBar="True" ShowIconOnTitleBar="False" ResizeMode="CanMinimize"
Title="CleanWindow" Height="350" Width="525" WindowStartupLocation="CenterScreen"
GlowBrush="{DynamicResource AccentColorBrush}"
Style="{DynamicResource MyCleanWindowStyle}">
<Controls:MetroWindow.Resources>
<ResourceDictionary>
<Style x:Key="MyCleanWindowStyle"
TargetType="{x:Type Controls:MetroWindow}"
BasedOn="{StaticResource CleanWindowStyleKey}"/>
...
</ResourceDictionary>
</Controls:MetroWindow.Resources>
...
<Grid>
</Grid>
</Controls:MetroWindow>
You mention wanting to set the Title, this is done by the code Title="CleanWindow"
. The property TitleCaps determines
whether the Title is displayed in all caps (CAPital letters) or not. The default is TitleCaps="True"
.
Upvotes: 1