Skip to content

Commit 6e53fba

Browse files
committed
Merge pull request #2256 from BlythMeister/FlyoutButtonCancel
Adding IsCancel="True" to Flyout button
2 parents e64229f + b4b7199 commit 6e53fba

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

MahApps.Metro/Controls/Flyout.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public event RoutedEventHandler ClosingFinished
5858
public static readonly DependencyProperty ThemeProperty = DependencyProperty.Register("Theme", typeof(FlyoutTheme), typeof(Flyout), new FrameworkPropertyMetadata(FlyoutTheme.Dark, ThemeChanged));
5959
public static readonly DependencyProperty ExternalCloseButtonProperty = DependencyProperty.Register("ExternalCloseButton", typeof(MouseButton), typeof(Flyout), new PropertyMetadata(MouseButton.Left));
6060
public static readonly DependencyProperty CloseButtonVisibilityProperty = DependencyProperty.Register("CloseButtonVisibility", typeof(Visibility), typeof(Flyout), new FrameworkPropertyMetadata(Visibility.Visible));
61+
public static readonly DependencyProperty CloseButtonIsCancelProperty = DependencyProperty.Register("CloseButtonIsCancel", typeof(bool), typeof(Flyout), new FrameworkPropertyMetadata(false));
6162
public static readonly DependencyProperty TitleVisibilityProperty = DependencyProperty.Register("TitleVisibility", typeof(Visibility), typeof(Flyout), new FrameworkPropertyMetadata(Visibility.Visible));
6263
public static readonly DependencyProperty AreAnimationsEnabledProperty = DependencyProperty.Register("AreAnimationsEnabled", typeof(bool), typeof(Flyout), new PropertyMetadata(true));
6364
public static readonly DependencyProperty FocusedElementProperty = DependencyProperty.Register("FocusedElement", typeof(FrameworkElement), typeof(Flyout), new UIPropertyMetadata(null));
@@ -90,6 +91,15 @@ public Visibility CloseButtonVisibility
9091
set { SetValue(CloseButtonVisibilityProperty, value); }
9192
}
9293

94+
/// <summary>
95+
/// Gets/sets if the close button is a cancel button in this flyout.
96+
/// </summary>
97+
public bool CloseButtonIsCancel
98+
{
99+
get { return (bool)GetValue(CloseButtonIsCancelProperty); }
100+
set { SetValue(CloseButtonIsCancelProperty, value); }
101+
}
102+
93103
/// <summary>
94104
/// An ICommand that executes when the flyout's close button is clicked.
95105
/// Note that this won't execute when <see cref="IsOpen"/> is set to <c>false</c>.

MahApps.Metro/Themes/Flyout.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
FontFamily="Segoe UI Symbol"
2727
Foreground="{Binding RelativeSource={RelativeSource AncestorType={x:Type Controls:Flyout}}, Path=Foreground}"
2828
FontSize="16"
29-
VerticalAlignment="Bottom">
29+
VerticalAlignment="Bottom"
30+
IsCancel="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:Flyout}}, Path=CloseButtonIsCancel}">
3031
<i:Interaction.Triggers>
3132
<i:EventTrigger EventName="Click">
3233
<Actions:SetFlyoutOpenAction TargetObject="{Binding RelativeSource={RelativeSource AncestorType={x:Type Controls:Flyout}}}"

samples/MetroDemo/ExampleWindows/FlyoutDemo.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@
147147
<Controls:Flyout Header="New Goodness"
148148
Position="Right"
149149
AnimateOpacity="True"
150-
Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Controls:MetroWindow}, Path=ActualWidth, Mode=OneWay}">
150+
Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Controls:MetroWindow}, Path=ActualWidth, Mode=OneWay}"
151+
CloseButtonIsCancel="True">
151152
<StackPanel Orientation="Vertical"
152153
Margin="10">
153154
<Button Content="create" />

0 commit comments

Comments
 (0)