From 3c2dfca17dd757823024043537f1093ac4c4edc0 Mon Sep 17 00:00:00 2001 From: mvschmaedeck Date: Fri, 13 Jan 2017 15:44:51 -0200 Subject: [PATCH] EXPOSE CLOSE BUTTON MARGIN PROPERTY FOR TAB ITEM Create a CloseButtonMargin property and a CloseButtonMarginProperty dependency property into MetroTabItem.cs sou users can change it from outside. --- .../Controls/MetroTabItem.cs | 19 ++++++++++++++++++- .../MahApps.Metro/Themes/MetroTabItem.xaml | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/MahApps.Metro/MahApps.Metro.Shared/Controls/MetroTabItem.cs b/src/MahApps.Metro/MahApps.Metro.Shared/Controls/MetroTabItem.cs index f4417fd64b..a0928b0379 100644 --- a/src/MahApps.Metro/MahApps.Metro.Shared/Controls/MetroTabItem.cs +++ b/src/MahApps.Metro/MahApps.Metro.Shared/Controls/MetroTabItem.cs @@ -59,7 +59,7 @@ private void AdjustCloseButton() closeButton = closeButton ?? GetTemplateChild("PART_CloseButton") as Button; if (closeButton != null) { - closeButton.Margin = newButtonMargin; + closeButton.Margin = CloseButtonMargin; } } @@ -128,5 +128,22 @@ public object CloseTabCommandParameter get { return GetValue(CloseTabCommandParameterProperty); } set { SetValue(CloseTabCommandParameterProperty, value); } } + + public static readonly DependencyProperty CloseButtonMarginProperty = + DependencyProperty.Register("CloseButtonMargin", + typeof(Thickness), + typeof(MetroTabItem), + new FrameworkPropertyMetadata(new Thickness(0,0,2,0), + FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.Inherits, + OnCloseButtonEnabledPropertyChangedCallback)); + + /// + /// Gets/sets the Close Button Margin. + /// + public Thickness CloseButtonMargin + { + get { return (Thickness)GetValue(CloseButtonMarginProperty); } + set { SetValue(CloseButtonEnabledProperty, value); } + } } } \ No newline at end of file diff --git a/src/MahApps.Metro/MahApps.Metro/Themes/MetroTabItem.xaml b/src/MahApps.Metro/MahApps.Metro/Themes/MetroTabItem.xaml index 64e07b04b8..642d98041e 100644 --- a/src/MahApps.Metro/MahApps.Metro/Themes/MetroTabItem.xaml +++ b/src/MahApps.Metro/MahApps.Metro/Themes/MetroTabItem.xaml @@ -43,7 +43,7 @@ CommandParameter="{TemplateBinding CloseTabCommandParameter}" Width="{TemplateBinding Controls:ControlsHelper.HeaderFontSize, Converter={StaticResource MetroTabItemCloseButtonWidthConverter}}" Height="{Binding RelativeSource={RelativeSource Self}, Path=Width, Mode=OneWay}" - Margin="0 0 2 0" + Margin="{DynamicResource CloseButtonMargin}" HorizontalAlignment="Right" VerticalAlignment="Top" Style="{DynamicResource ChromelessButtonStyle}"