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

Visual bug while using RightWindowCommands #2449

Closed
PavelLvou opened this issue Mar 25, 2016 · 7 comments
Closed

Visual bug while using RightWindowCommands #2449

PavelLvou opened this issue Mar 25, 2016 · 7 comments
Milestone

Comments

@PavelLvou
Copy link

What steps will reproduce this issue?

Hello,
I have a problem.
Gray rectangle appears if window lose focus
I try find this elements and find next

fullversion

Here xaml

<controls:MetroWindow  ResizeMode="NoResize"
        EnableDWMDropShadow="False"  WindowTransitionsEnabled="False"
        ShowMaxRestoreButton="False" ShowCloseButton="False" ShowMinButton="False" ShowIconOnTitleBar="False"
        WindowStyle="None" AllowsTransparency="True" WindowTitleBrush="Transparent" BorderBrush="Transparent" Background="Transparent"
        TitlebarHeight="100" Height="630" Width="450">
    <controls:MetroWindow.RightWindowCommands>
        <controls:WindowCommands Background="Transparent">
            <Border x:Name="RootBorder" BorderBrush="Red"
                    Width="450" Height="100"
                    BorderThickness="2, 2, 2, 0" CornerRadius="7,7,0,0"
                    Background="Green">
                <Label Content="Title"></Label>
            </Border>
        </controls:WindowCommands>
    </controls:MetroWindow.RightWindowCommands>
    <Border Width="450" BorderThickness="2, 0, 2, 2" CornerRadius="0, 0, 7, 7" BorderBrush="Red" Background="DarkGreen">
        <Label Content="Body"></Label>
    </Border>
</controls:MetroWindow>

Expected outcome

All my elements have width 450
Why I have element whose width more than my elements and how I can fix it?
And why I have this gray rectangle after window lose focus?

Thank you

Environment

  • MahApps.Metro v1.2.4.0
  • Windows 7
  • Visual Studio 2015
  • .NET Framework 4.6
@punker76
Copy link
Member

@PavelLvou So you customize the custom MahApps solution. Here some points which you should know (latest source)

  • WindowStyle is already None
  • MahApps doesn't support AllowsTransparency="True" cause it has some nasty side effects
  • you must set AllowsTransparency="True" in the Initialized event
  • set also NonActiveWindowTitleBrush="Transparent"

2016-03-25_23h09_21

@PavelLvou
Copy link
Author

Thanks, but I still have problem
All my elements have width 450
Why I have element whose width more than my elements?
And still after lose focus window have gray border
fullversionv2

@sergey-tihon
Copy link

@punker76 Could you please help to fix #2449 (comment)

@punker76
Copy link
Member

@sergey-tihon @PavelLvou Here is my testcase with the latest source and using the TitleTemplate instead the RightWindowCommands

<controls:MetroWindow x:Class="MetroDemo.ExampleWindows.AllowTransparencyDemo"
                      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"
                      Width="450"
                      Height="630"
                      Background="Transparent"
                      BorderBrush="Transparent"
                      EnableDWMDropShadow="False"
                      Initialized="AllowTransparencyDemo_OnInitialized"
                      NonActiveBorderBrush="Transparent"
                      NonActiveWindowTitleBrush="Transparent"
                      ResizeMode="NoResize"
                      ShowCloseButton="False"
                      ShowIconOnTitleBar="False"
                      ShowMaxRestoreButton="False"
                      ShowMinButton="False"
                      TitlebarHeight="100"
                      WindowTitleBrush="Transparent"
                      WindowTransitionsEnabled="False">

    <controls:MetroWindow.TitleTemplate>
        <DataTemplate>
            <Border x:Name="RootBorder"
                    Background="Green"
                    BorderBrush="Red"
                    BorderThickness="2 2 2 0"
                    CornerRadius="7,7,0,0">
                <Label Content="Title" />
            </Border>
        </DataTemplate>
    </controls:MetroWindow.TitleTemplate>

    <Border Background="DarkGreen"
            BorderBrush="Red"
            BorderThickness="2 0 2 2"
            CornerRadius="0, 0, 7, 7">
        <Label Content="Body" />
    </Border>

</controls:MetroWindow>
public partial class AllowTransparencyDemo : MetroWindow
{
    public AllowTransparencyDemo()
    {
        InitializeComponent();
    }

    private void AllowTransparencyDemo_OnInitialized(object sender, EventArgs e)
    {
        this.AllowsTransparency = true;
    }
}

2016-04-12_22h04_16

@JinOptimist
Copy link

@punker76
But here #2288 (comment)
you say use another.
I have a problem, my button in title aren't clickable, because there lays an invisible grid

@PavelLvou
Copy link
Author

Hi, can you answer, is it possible avoid both of problems, please?
If I use TitleTemplate, than I can't use button into Title. Here example
If I use RightWindowCommands, than I have problem with layout.

@punker76
Copy link
Member

@PavelLvou @JinOptimist The problem is the introduced thumb for drag&move, it will be fixed with #2477

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

No branches or pull requests

4 participants