Skip to content

Commit

Permalink
(GH-3244) Left-/ RightWindowCommands no more visible when ShowTitleBa…
Browse files Browse the repository at this point in the history
…r is False

  This feature will be there, but the window commands can now be used again to bring these back
  • Loading branch information
punker76 committed May 11, 2018
1 parent d99b032 commit b2e86a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
<Window.Resources>
<ResourceDictionary>

<x:Array x:Key="WindowCommandsOverlayBehaviorArray" Type="Controls:WindowCommandsOverlayBehavior">
<Controls:WindowCommandsOverlayBehavior>Always</Controls:WindowCommandsOverlayBehavior>
<Controls:WindowCommandsOverlayBehavior>Flyouts</Controls:WindowCommandsOverlayBehavior>
<Controls:WindowCommandsOverlayBehavior>HiddenTitleBar</Controls:WindowCommandsOverlayBehavior>
<Controls:WindowCommandsOverlayBehavior>Never</Controls:WindowCommandsOverlayBehavior>
</x:Array>
<ObjectDataProvider x:Key="WindowCommandsOverlayBehaviorValues"
MethodName="GetValues"
ObjectType="{x:Type Controls:WindowCommandsOverlayBehavior}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="Controls:WindowCommandsOverlayBehavior" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>

</ResourceDictionary>
</Window.Resources>
Expand Down Expand Up @@ -445,7 +446,7 @@
Width="100"
Margin="2"
VerticalAlignment="Center"
ItemsSource="{StaticResource WindowCommandsOverlayBehaviorArray}"
ItemsSource="{Binding Source={StaticResource WindowCommandsOverlayBehaviorValues}}"
SelectedValue="{Binding ElementName=flyoutsDemo, Path=LeftWindowCommandsOverlayBehavior}" />
</Grid>

Expand All @@ -462,7 +463,7 @@
Width="100"
Margin="2"
VerticalAlignment="Center"
ItemsSource="{StaticResource WindowCommandsOverlayBehaviorArray}"
ItemsSource="{Binding Source={StaticResource WindowCommandsOverlayBehaviorValues}}"
SelectedValue="{Binding ElementName=flyoutsDemo, Path=RightWindowCommandsOverlayBehavior}" />
</Grid>

Expand All @@ -479,7 +480,7 @@
Width="100"
Margin="2"
VerticalAlignment="Center"
ItemsSource="{StaticResource WindowCommandsOverlayBehaviorArray}"
ItemsSource="{Binding Source={StaticResource WindowCommandsOverlayBehaviorValues}}"
SelectedValue="{Binding ElementName=flyoutsDemo, Path=WindowButtonCommandsOverlayBehavior}" />
</Grid>

Expand All @@ -496,10 +497,12 @@
Width="100"
Margin="2"
VerticalAlignment="Center"
ItemsSource="{StaticResource WindowCommandsOverlayBehaviorArray}"
ItemsSource="{Binding Source={StaticResource WindowCommandsOverlayBehaviorValues}}"
SelectedValue="{Binding ElementName=flyoutsDemo, Path=IconOverlayBehavior}" />
</Grid>

<CheckBox Content="ShowTitleBar" IsChecked="{Binding ElementName=flyoutsDemo, Path=ShowTitleBar, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

<Button Margin="2 10 2 2"
Click="ShowLeft"
Content="Show Left" />
Expand Down
20 changes: 10 additions & 10 deletions src/MahApps.Metro/Controls/MetroWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ public class MetroWindow : Window
public static readonly DependencyProperty RightWindowCommandsProperty = DependencyProperty.Register("RightWindowCommands", typeof(WindowCommands), typeof(MetroWindow), new PropertyMetadata(null, UpdateLogicalChilds));
public static readonly DependencyProperty WindowButtonCommandsProperty = DependencyProperty.Register("WindowButtonCommands", typeof(WindowButtonCommands), typeof(MetroWindow), new PropertyMetadata(null, UpdateLogicalChilds));

public static readonly DependencyProperty LeftWindowCommandsOverlayBehaviorProperty = DependencyProperty.Register("LeftWindowCommandsOverlayBehavior", typeof(WindowCommandsOverlayBehavior), typeof(MetroWindow), new PropertyMetadata(WindowCommandsOverlayBehavior.Flyouts));
public static readonly DependencyProperty RightWindowCommandsOverlayBehaviorProperty = DependencyProperty.Register("RightWindowCommandsOverlayBehavior", typeof(WindowCommandsOverlayBehavior), typeof(MetroWindow), new PropertyMetadata(WindowCommandsOverlayBehavior.Flyouts));
public static readonly DependencyProperty WindowButtonCommandsOverlayBehaviorProperty = DependencyProperty.Register("WindowButtonCommandsOverlayBehavior", typeof(WindowCommandsOverlayBehavior), typeof(MetroWindow), new PropertyMetadata(WindowCommandsOverlayBehavior.Always));
public static readonly DependencyProperty IconOverlayBehaviorProperty = DependencyProperty.Register("IconOverlayBehavior", typeof(WindowCommandsOverlayBehavior), typeof(MetroWindow), new PropertyMetadata(WindowCommandsOverlayBehavior.Never));
public static readonly DependencyProperty LeftWindowCommandsOverlayBehaviorProperty = DependencyProperty.Register("LeftWindowCommandsOverlayBehavior", typeof(WindowCommandsOverlayBehavior), typeof(MetroWindow), new PropertyMetadata(WindowCommandsOverlayBehavior.Flyouts, OnShowTitleBarPropertyChangedCallback));
public static readonly DependencyProperty RightWindowCommandsOverlayBehaviorProperty = DependencyProperty.Register("RightWindowCommandsOverlayBehavior", typeof(WindowCommandsOverlayBehavior), typeof(MetroWindow), new PropertyMetadata(WindowCommandsOverlayBehavior.Flyouts, OnShowTitleBarPropertyChangedCallback));
public static readonly DependencyProperty WindowButtonCommandsOverlayBehaviorProperty = DependencyProperty.Register("WindowButtonCommandsOverlayBehavior", typeof(WindowCommandsOverlayBehavior), typeof(MetroWindow), new PropertyMetadata(WindowCommandsOverlayBehavior.Always, OnShowTitleBarPropertyChangedCallback));
public static readonly DependencyProperty IconOverlayBehaviorProperty = DependencyProperty.Register("IconOverlayBehavior", typeof(WindowCommandsOverlayBehavior), typeof(MetroWindow), new PropertyMetadata(WindowCommandsOverlayBehavior.Never, OnShowTitleBarPropertyChangedCallback));

[Obsolete(@"This property will be deleted in the next release. You should use LightMinButtonStyle or DarkMinButtonStyle in WindowButtonCommands to override the style.")]
public static readonly DependencyProperty WindowMinButtonStyleProperty = DependencyProperty.Register("WindowMinButtonStyle", typeof(Style), typeof(MetroWindow), new PropertyMetadata(null, OnWindowButtonStyleChanged));
Expand Down Expand Up @@ -621,14 +621,14 @@ private void SetVisibiltyForAllTitleElements()
this.titleBar?.SetCurrentValue(VisibilityProperty, newVisibility);
this.titleBarBackground?.SetCurrentValue(VisibilityProperty, newVisibility);

newVisibility = this.LeftWindowCommandsOverlayBehavior.HasFlag(WindowCommandsOverlayBehavior.HiddenTitleBar) && !this.UseNoneWindowStyle ? Visibility.Visible : newVisibility;
this.LeftWindowCommandsPresenter?.SetCurrentValue(VisibilityProperty, newVisibility);
var leftWindowCommandsVisibility = this.LeftWindowCommandsOverlayBehavior.HasFlag(WindowCommandsOverlayBehavior.HiddenTitleBar) && !this.UseNoneWindowStyle ? Visibility.Visible : newVisibility;
this.LeftWindowCommandsPresenter?.SetCurrentValue(VisibilityProperty, leftWindowCommandsVisibility);

newVisibility = this.RightWindowCommandsOverlayBehavior.HasFlag(WindowCommandsOverlayBehavior.HiddenTitleBar) && !this.UseNoneWindowStyle ? Visibility.Visible : newVisibility;
this.RightWindowCommandsPresenter?.SetCurrentValue(VisibilityProperty, newVisibility);
var rightWindowCommandsVisibility = this.RightWindowCommandsOverlayBehavior.HasFlag(WindowCommandsOverlayBehavior.HiddenTitleBar) && !this.UseNoneWindowStyle ? Visibility.Visible : newVisibility;
this.RightWindowCommandsPresenter?.SetCurrentValue(VisibilityProperty, rightWindowCommandsVisibility);

newVisibility = this.WindowButtonCommandsOverlayBehavior.HasFlag(WindowCommandsOverlayBehavior.HiddenTitleBar) ? Visibility.Visible : newVisibility;
this.WindowButtonCommandsPresenter?.SetCurrentValue(VisibilityProperty, newVisibility);
var windowButtonCommandsVisibility = this.WindowButtonCommandsOverlayBehavior.HasFlag(WindowCommandsOverlayBehavior.HiddenTitleBar) ? Visibility.Visible : newVisibility;
this.WindowButtonCommandsPresenter?.SetCurrentValue(VisibilityProperty, windowButtonCommandsVisibility);

this.SetWindowEvents();
}
Expand Down

0 comments on commit b2e86a1

Please sign in to comment.