MahApps / MahApps.Metro

A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.
https://mahapps.com
MIT License
9.32k stars 2.45k forks source link

Window Style goes wrong #3516

Closed wunianqing closed 5 years ago

wunianqing commented 5 years ago

Describe the bug Original window style can be seen when switch window in Win7.

To Reproduce Steps to reproduce the behavior:

  1. Open demo application. Notice the top-left corner and top-right corner of window.
  2. Open VS window.
  3. Switch between VS window and main window. Notice the style of VS window.
  4. See error
  5. Maximize and restore VS window. Switch between windows. Style won't change anymore.

Expected behavior CornerRadius should be 0. And style of window should not change.

Screenshots [Expected] Expected
[Actual] Actual
[Screen record] record

Environment(please complete the following information):

Additional context This only happen in some real machines. But it can be easy reproduced on virtual machine. And once you set Performance Options -> Visual Effects -> Adjust for best performance. This problem will no longer exist.

wunianqing commented 5 years ago

I just found that version 1.6 and 1.6.1 are good. I cannot compile the 1.6.2, 1.6.3 and 1.6.4. And 1.6.5 is NG.

punker76 commented 5 years ago

@wunianqing This is related to the new/changed implementation of the borderless behavior in ControlzEx v4.0 alpha.

/cc @batzen I can reproduce this in a Win7 test VM, but didn't know how to solve this. (Another effect is while changing focus from Window to another Window is that the win 7 aero theme is shown for one second. I don't know if I want to fix this... 🙈 )

2019-06-03_12h50_42

mahapps_controlzex_win7

batzen commented 5 years ago

@punker76 Could you move this issue to ControlzEx? Will have a look at this.

punker76 commented 5 years ago

@batzen Transfering issues is only allowed in the same organization level, so I will create a new one at ControlzEx and reference this one.

punker76 commented 5 years ago

https://github.com/ControlzEx/ControlzEx/issues/80

wunianqing commented 5 years ago

Thx. @punker76 I replaced the InitializeWindowChromeBehavior in MetroWinow.cs with the following code before issue is fixed. For now, it works fine. I don't know if this will cause other problems.

        private void InitializeWindowChromeBehavior()
        {
            WindowStyle = WindowStyle.None;
            WindowChrome.SetWindowChrome(this, new WindowChrome()
            {
                CaptionHeight = 0,
                CornerRadius = new CornerRadius(0.0),
                GlassFrameThickness = new Thickness(1),
                UseAeroCaptionButtons = false,
                NonClientFrameEdges = NonClientFrameEdges.None
            });
            //var behavior = new BorderlessWindowBehavior();
            //Interaction.GetBehaviors(this).Add(behavior);
        }