Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CleanWindow.xaml ruins my Close Button #2609

Closed
ghost opened this issue Aug 14, 2016 · 1 comment
Closed

CleanWindow.xaml ruins my Close Button #2609

ghost opened this issue Aug 14, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 14, 2016

When i add CleanWindow.xaml to my project, my close button isn't red anymore but blue when being pressed.

I want the button to be red when being pressed and at the same time have working RightWindowCommands and CleanWindow.

Here's the code:

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 MyCleanWindowStyle}">

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Clean/CleanWindow.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style x:Key="MyCleanWindowStyle" TargetType="{x:Type Controls:MetroWindow}" BasedOn="{StaticResource CleanWindowStyleKey}" />
        </ResourceDictionary>
    </Window.Resources>

    <Controls:MetroWindow.RightWindowCommands>
        <Controls:WindowCommands>
            <Button Content="settings" />
        </Controls:WindowCommands>
    </Controls:MetroWindow.RightWindowCommands>

    <Grid>

    </Grid>
</Controls:MetroWindow>

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/BaseDark.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

MainWindow.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MahApps.Metro.Controls;

namespace Twitch_Notifier
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : MetroWindow
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}

Thank you for you suggestions and solutions!

@Evangelink
Copy link
Contributor

I might have an uncomplete answer but it your MainWindow.xaml, if you do this:

<Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Clean/Clean.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style x:Key="MyCleanWindowStyle" TargetType="{x:Type Controls:MetroWindow}" BasedOn="{StaticResource CleanWindowStyleKey}" />
        </ResourceDictionary>
    </Window.Resources>

instead of this:

<Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Clean/CleanWindow.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style x:Key="MyCleanWindowStyle" TargetType="{x:Type Controls:MetroWindow}" BasedOn="{StaticResource CleanWindowStyleKey}" />
        </ResourceDictionary>
    </Window.Resources>

You end up with a close button of a red color when pressed.

Hope that it will make it for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants