Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXPOSE CLOSE BUTTON MARGIN PROPERTY FOR TAB ITEM #2803

Merged
merged 2 commits into from
Feb 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/MahApps.Metro/MahApps.Metro.Shared/Controls/MetroTabItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void AdjustCloseButton()
closeButton = closeButton ?? GetTemplateChild("PART_CloseButton") as Button;
if (closeButton != null)
{
closeButton.Margin = newButtonMargin;
closeButton.Margin = CloseButtonMargin;
}
}

Expand Down Expand Up @@ -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));

/// <summary>
/// Gets/sets the Close Button Margin.
/// </summary>
public Thickness CloseButtonMargin
{
get { return (Thickness)GetValue(CloseButtonMarginProperty); }
set { SetValue(CloseButtonEnabledProperty, value); }
}
}
}
2 changes: 1 addition & 1 deletion src/MahApps.Metro/MahApps.Metro/Themes/MetroTabItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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}"
VerticalAlignment="Top"
Style="{DynamicResource ChromelessButtonStyle}"
Background="{DynamicResource GrayNormalBrush}"
Expand Down