From 949232df6c1daaccb559fd523d0fce61c13ca1b0 Mon Sep 17 00:00:00 2001 From: jammerxd Date: Sat, 9 Sep 2017 15:06:13 -0500 Subject: [PATCH] Added underline position for allowing the underline position to be set regardless of the tabstripplacement property on the tab controls, works with animated, regular and animated single row tab controls --- .../ExampleViews/TabControlExamples.xaml | 12 +- .../Controls/Helper/TabControlHelper.cs | 25 ++ .../Controls.AnimatedSingleRowTabControl.xaml | 186 +++++++++++++- .../Styles/Controls.AnimatedTabControl.xaml | 182 ++++++++++++- .../Styles/Controls.TabControl.xaml | 224 ++++++++++++++-- .../MahApps.Metro/Themes/MetroTabControl.xaml | 3 - .../MahApps.Metro/Themes/MetroTabItem.xaml | 240 +++++++++++++++++- 7 files changed, 828 insertions(+), 44 deletions(-) diff --git a/src/MahApps.Metro.Samples/MahApps.Metro.Demo/MahApps.Metro.Demo.Shared/ExampleViews/TabControlExamples.xaml b/src/MahApps.Metro.Samples/MahApps.Metro.Demo/MahApps.Metro.Demo.Shared/ExampleViews/TabControlExamples.xaml index 9e8a53d8cd..68ee66b9e3 100644 --- a/src/MahApps.Metro.Samples/MahApps.Metro.Demo/MahApps.Metro.Demo.Shared/ExampleViews/TabControlExamples.xaml +++ b/src/MahApps.Metro.Samples/MahApps.Metro.Demo/MahApps.Metro.Demo.Shared/ExampleViews/TabControlExamples.xaml @@ -54,11 +54,11 @@ HorizontalAlignment="Left" VerticalAlignment="Center" ItemsSource="{Binding Source={StaticResource TabStripPlacementEnumValues}}" - SelectedItem="{x:Static Dock.Top}" /> + SelectedItem="{x:Static Dock.Right}" /> + TabStripPlacement="{Binding ElementName=TabStripPlacementComboBox, Path=SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Controls:TabControlHelper.UnderlinePosition="Right"> @@ -110,7 +110,7 @@ + TabStripPlacement="{Binding ElementName=AnimatedTabControlTabStripPlacementComboBox, Path=SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Controls:TabControlHelper.UnderlinePosition="Left"> @@ -154,7 +154,7 @@ + TabStripPlacement="{Binding ElementName=AnimatedSingleRowTabControlTabStripPlacementComboBox, Path=SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Controls:TabControlHelper.UnderlinePosition="Top"> @@ -202,7 +202,7 @@ + TabStripPlacement="{Binding ElementName=MetroAnimatedTabControlTabStripPlacementComboBox, Path=SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Controls:TabControlHelper.UnderlinePosition="Bottom"> @@ -241,7 +241,7 @@ + TabStripPlacement="{Binding ElementName=MetroAnimatedSingleRowTabControlTabStripPlacementComboBox, Path=SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Controls:TabControlHelper.UnderlinePosition="Right"> diff --git a/src/MahApps.Metro/MahApps.Metro.Shared/Controls/Helper/TabControlHelper.cs b/src/MahApps.Metro/MahApps.Metro.Shared/Controls/Helper/TabControlHelper.cs index 40f225ba38..7c4094d180 100644 --- a/src/MahApps.Metro/MahApps.Metro.Shared/Controls/Helper/TabControlHelper.cs +++ b/src/MahApps.Metro/MahApps.Metro.Shared/Controls/Helper/TabControlHelper.cs @@ -176,5 +176,30 @@ public static void SetTransition(DependencyObject obj, TransitionType value) { obj.SetValue(TransitionProperty, value); } + + + + /// + /// Defines the position of the Underline + /// + + public static readonly DependencyProperty UnderlinePositionProperty = + DependencyProperty.RegisterAttached("UnderlinePosition", + typeof(Dock), + typeof(TabControlHelper), + new PropertyMetadata(Dock.Bottom) + ); + + [Category(AppName.MahApps)] + [AttachedPropertyBrowsableForType(typeof(TabControl))] + public static Dock GetUnderlinePosition(UIElement element) + { + return (Dock)element.GetValue(UnderlinePositionProperty); + } + + public static void SetUnderlinePosition(UIElement element, Dock value) + { + element.SetValue(UnderlinePositionProperty, value); + } } } diff --git a/src/MahApps.Metro/MahApps.Metro/Styles/Controls.AnimatedSingleRowTabControl.xaml b/src/MahApps.Metro/MahApps.Metro/Styles/Controls.AnimatedSingleRowTabControl.xaml index 1df290d09c..8cc9733c7d 100644 --- a/src/MahApps.Metro/MahApps.Metro/Styles/Controls.AnimatedSingleRowTabControl.xaml +++ b/src/MahApps.Metro/MahApps.Metro/Styles/Controls.AnimatedSingleRowTabControl.xaml @@ -235,7 +235,6 @@ - @@ -243,8 +242,98 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -296,7 +385,6 @@ - @@ -304,9 +392,98 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/MahApps.Metro/MahApps.Metro/Styles/Controls.AnimatedTabControl.xaml b/src/MahApps.Metro/MahApps.Metro/Styles/Controls.AnimatedTabControl.xaml index e1741bdf3b..800b6ee0e3 100644 --- a/src/MahApps.Metro/MahApps.Metro/Styles/Controls.AnimatedTabControl.xaml +++ b/src/MahApps.Metro/MahApps.Metro/Styles/Controls.AnimatedTabControl.xaml @@ -69,7 +69,6 @@ - @@ -81,7 +80,6 @@ - @@ -93,11 +91,189 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/MahApps.Metro/MahApps.Metro/Styles/Controls.TabControl.xaml b/src/MahApps.Metro/MahApps.Metro/Styles/Controls.TabControl.xaml index fc782f0ccf..1961f9717f 100644 --- a/src/MahApps.Metro/MahApps.Metro/Styles/Controls.TabControl.xaml +++ b/src/MahApps.Metro/MahApps.Metro/Styles/Controls.TabControl.xaml @@ -11,6 +11,7 @@ + @@ -65,7 +66,6 @@ - @@ -77,7 +77,6 @@ - @@ -89,8 +88,9 @@ - + + @@ -150,8 +150,8 @@ SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" UseLayoutRounding="False" /> - - - @@ -181,9 +178,6 @@ - - - @@ -192,9 +186,6 @@ - - - @@ -203,9 +194,6 @@ - - - @@ -219,6 +207,30 @@ + + + + + @@ -272,6 +284,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/MahApps.Metro/MahApps.Metro/Themes/MetroTabControl.xaml b/src/MahApps.Metro/MahApps.Metro/Themes/MetroTabControl.xaml index 685de74df6..ae56c8a299 100644 --- a/src/MahApps.Metro/MahApps.Metro/Themes/MetroTabControl.xaml +++ b/src/MahApps.Metro/MahApps.Metro/Themes/MetroTabControl.xaml @@ -59,7 +59,6 @@ - @@ -70,7 +69,6 @@ - @@ -81,7 +79,6 @@ - diff --git a/src/MahApps.Metro/MahApps.Metro/Themes/MetroTabItem.xaml b/src/MahApps.Metro/MahApps.Metro/Themes/MetroTabItem.xaml index 21abc33a4f..330e634fb6 100644 --- a/src/MahApps.Metro/MahApps.Metro/Themes/MetroTabItem.xaml +++ b/src/MahApps.Metro/MahApps.Metro/Themes/MetroTabItem.xaml @@ -111,9 +111,6 @@ - - - @@ -122,9 +119,6 @@ - - - @@ -133,9 +127,6 @@ - - - @@ -144,9 +135,6 @@ - - - @@ -238,6 +226,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +