@@ -124,8 +124,8 @@ public class MetroWindow : Window
124
124
public static readonly DependencyProperty RightWindowCommandsProperty = DependencyProperty . Register ( "RightWindowCommands" , typeof ( WindowCommands ) , typeof ( MetroWindow ) , new PropertyMetadata ( null , UpdateLogicalChilds ) ) ;
125
125
public static readonly DependencyProperty WindowButtonCommandsProperty = DependencyProperty . Register ( "WindowButtonCommands" , typeof ( WindowButtonCommands ) , typeof ( MetroWindow ) , new PropertyMetadata ( null , UpdateLogicalChilds ) ) ;
126
126
127
- public static readonly DependencyProperty LeftWindowCommandsOverlayBehaviorProperty = DependencyProperty . Register ( "LeftWindowCommandsOverlayBehavior" , typeof ( WindowCommandsOverlayBehavior ) , typeof ( MetroWindow ) , new PropertyMetadata ( WindowCommandsOverlayBehavior . Always ) ) ;
128
- public static readonly DependencyProperty RightWindowCommandsOverlayBehaviorProperty = DependencyProperty . Register ( "RightWindowCommandsOverlayBehavior" , typeof ( WindowCommandsOverlayBehavior ) , typeof ( MetroWindow ) , new PropertyMetadata ( WindowCommandsOverlayBehavior . Always ) ) ;
127
+ public static readonly DependencyProperty LeftWindowCommandsOverlayBehaviorProperty = DependencyProperty . Register ( "LeftWindowCommandsOverlayBehavior" , typeof ( WindowCommandsOverlayBehavior ) , typeof ( MetroWindow ) , new PropertyMetadata ( WindowCommandsOverlayBehavior . Flyouts ) ) ;
128
+ public static readonly DependencyProperty RightWindowCommandsOverlayBehaviorProperty = DependencyProperty . Register ( "RightWindowCommandsOverlayBehavior" , typeof ( WindowCommandsOverlayBehavior ) , typeof ( MetroWindow ) , new PropertyMetadata ( WindowCommandsOverlayBehavior . Flyouts ) ) ;
129
129
public static readonly DependencyProperty WindowButtonCommandsOverlayBehaviorProperty = DependencyProperty . Register ( "WindowButtonCommandsOverlayBehavior" , typeof ( WindowCommandsOverlayBehavior ) , typeof ( MetroWindow ) , new PropertyMetadata ( WindowCommandsOverlayBehavior . Always ) ) ;
130
130
public static readonly DependencyProperty IconOverlayBehaviorProperty = DependencyProperty . Register ( "IconOverlayBehavior" , typeof ( WindowCommandsOverlayBehavior ) , typeof ( MetroWindow ) , new PropertyMetadata ( WindowCommandsOverlayBehavior . Never ) ) ;
131
131
@@ -474,7 +474,7 @@ private static void OnShowTitleBarPropertyChangedCallback(DependencyObject d, De
474
474
var window = ( MetroWindow ) d ;
475
475
if ( e . NewValue != e . OldValue )
476
476
{
477
- window . SetVisibiltyForAllTitleElements ( ( bool ) e . NewValue ) ;
477
+ window . SetVisibiltyForAllTitleElements ( ) ;
478
478
}
479
479
}
480
480
@@ -503,29 +503,12 @@ private static void OnUseNoneWindowStylePropertyChangedCallback(DependencyObject
503
503
{
504
504
// if UseNoneWindowStyle = true no title bar should be shown
505
505
var useNoneWindowStyle = ( bool ) e . NewValue ;
506
- var window = ( MetroWindow ) d ;
507
- window . ToggleNoneWindowStyle ( useNoneWindowStyle , window . ShowTitleBar ) ;
508
- }
509
- }
510
506
511
- private void ToggleNoneWindowStyle ( bool useNoneWindowStyle , bool isTitleBarVisible )
512
- {
513
- // UseNoneWindowStyle means no title bar, window commands or min, max, close buttons
514
- if ( useNoneWindowStyle )
515
- {
516
- this . SetCurrentValue ( ShowTitleBarProperty , false ) ;
517
- }
518
- else
519
- {
520
- this . SetCurrentValue ( ShowTitleBarProperty , isTitleBarVisible ) ;
521
- }
522
- if ( LeftWindowCommandsPresenter != null )
523
- {
524
- LeftWindowCommandsPresenter . Visibility = useNoneWindowStyle ? Visibility . Collapsed : Visibility . Visible ;
525
- }
526
- if ( RightWindowCommandsPresenter != null )
527
- {
528
- RightWindowCommandsPresenter . Visibility = useNoneWindowStyle ? Visibility . Collapsed : Visibility . Visible ;
507
+ // UseNoneWindowStyle means no title bar, window commands or min, max, close buttons
508
+ if ( useNoneWindowStyle )
509
+ {
510
+ ( ( MetroWindow ) d ) . SetCurrentValue ( ShowTitleBarProperty , false ) ;
511
+ }
529
512
}
530
513
}
531
514
@@ -615,7 +598,7 @@ private static void TitlebarHeightPropertyChangedCallback(DependencyObject depen
615
598
var window = ( MetroWindow ) dependencyObject ;
616
599
if ( e . NewValue != e . OldValue )
617
600
{
618
- window . SetVisibiltyForAllTitleElements ( ( int ) e . NewValue > 0 ) ;
601
+ window . SetVisibiltyForAllTitleElements ( ) ;
619
602
}
620
603
}
621
604
@@ -630,24 +613,24 @@ private void SetVisibiltyForIcon()
630
613
}
631
614
}
632
615
633
- private void SetVisibiltyForAllTitleElements ( bool visible )
616
+ private void SetVisibiltyForAllTitleElements ( )
634
617
{
635
618
this . SetVisibiltyForIcon ( ) ;
636
- var newVisibility = visible && this . ShowTitleBar ? Visibility . Visible : Visibility . Collapsed ;
619
+ var newVisibility = this . TitlebarHeight > 0 && this . ShowTitleBar && ! this . UseNoneWindowStyle ? Visibility . Visible : Visibility . Collapsed ;
637
620
638
621
this . titleBar ? . SetCurrentValue ( VisibilityProperty , newVisibility ) ;
639
622
this . titleBarBackground ? . SetCurrentValue ( VisibilityProperty , newVisibility ) ;
640
623
641
- newVisibility = this . LeftWindowCommandsOverlayBehavior . HasFlag ( WindowCommandsOverlayBehavior . HiddenTitleBar ) ? Visibility . Visible : newVisibility ;
624
+ newVisibility = this . LeftWindowCommandsOverlayBehavior . HasFlag ( WindowCommandsOverlayBehavior . HiddenTitleBar ) && ! this . UseNoneWindowStyle ? Visibility . Visible : newVisibility ;
642
625
this . LeftWindowCommandsPresenter ? . SetCurrentValue ( VisibilityProperty , newVisibility ) ;
643
626
644
- newVisibility = this . RightWindowCommandsOverlayBehavior . HasFlag ( WindowCommandsOverlayBehavior . HiddenTitleBar ) ? Visibility . Visible : newVisibility ;
627
+ newVisibility = this . RightWindowCommandsOverlayBehavior . HasFlag ( WindowCommandsOverlayBehavior . HiddenTitleBar ) && ! this . UseNoneWindowStyle ? Visibility . Visible : newVisibility ;
645
628
this . RightWindowCommandsPresenter ? . SetCurrentValue ( VisibilityProperty , newVisibility ) ;
646
629
647
630
newVisibility = this . WindowButtonCommandsOverlayBehavior . HasFlag ( WindowCommandsOverlayBehavior . HiddenTitleBar ) ? Visibility . Visible : newVisibility ;
648
631
this . WindowButtonCommandsPresenter ? . SetCurrentValue ( VisibilityProperty , newVisibility ) ;
649
632
650
- SetWindowEvents ( ) ;
633
+ this . SetWindowEvents ( ) ;
651
634
}
652
635
653
636
/// <summary>
@@ -1044,8 +1027,6 @@ private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
1044
1027
VisualStateManager . GoToState ( this , "AfterLoaded" , true ) ;
1045
1028
}
1046
1029
1047
- this . ToggleNoneWindowStyle ( this . UseNoneWindowStyle , this . ShowTitleBar ) ;
1048
-
1049
1030
if ( this . Flyouts == null )
1050
1031
{
1051
1032
this . Flyouts = new FlyoutsControl ( ) ;
@@ -1243,7 +1224,7 @@ public override void OnApplyTemplate()
1243
1224
this . windowTitleThumb = GetTemplateChild ( PART_WindowTitleThumb ) as Thumb ;
1244
1225
this . flyoutModalDragMoveThumb = GetTemplateChild ( PART_FlyoutModalDragMoveThumb ) as Thumb ;
1245
1226
1246
- this . SetVisibiltyForAllTitleElements ( this . TitlebarHeight > 0 ) ;
1227
+ this . SetVisibiltyForAllTitleElements ( ) ;
1247
1228
1248
1229
var metroContentControl = GetTemplateChild ( PART_Content ) as MetroContentControl ;
1249
1230
if ( metroContentControl != null )
0 commit comments