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

Tab Control Underline Position #3524

Merged
merged 23 commits into from
Jun 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
949232d
Added underline position for allowing the underline position to be se…
jammerxd Sep 9, 2017
8fc26d4
Merge branch 'develop' of https://github.com/MahApps/MahApps.Metro in…
jammerxd Sep 9, 2017
2eaa021
Merge branch 'develop' into tcunderline_position
punker76 Sep 11, 2017
ddbc5ee
Merge branch 'develop' into tcunderline_position
punker76 Sep 15, 2017
9ee4c4a
Merge branch 'develop' into tcunderline_position
punker76 Sep 15, 2017
5a8683c
Merge branch 'develop' into tcunderline_position
punker76 Oct 6, 2017
07f4fd9
Merge branch 'develop' into tcunderline_position
punker76 Oct 13, 2017
3775342
Merge branch 'develop' into tcunderline_position
punker76 Oct 16, 2017
c8c50da
Merge branch 'develop' into tcunderline_position
punker76 Jan 14, 2018
e0da94b
Merge branch 'develop' into tcunderline_position
punker76 Feb 2, 2018
0f70579
Add initial remember checkbox checked
Evangelink Jun 4, 2019
f23a68f
Merge branch 'develop' of https://github.com/Evangelink/MahApps.Metro…
Evangelink Jun 6, 2019
4b2c072
Merge branch 'develop' into tcunderline_position
Evangelink Jun 6, 2019
6680f3e
Merge branch 'develop' into tcunderline_position
Evangelink Jun 6, 2019
21305dd
Improve demo experience
Evangelink Jun 6, 2019
3c0e416
Rename UnderlinePosition in UnderlinePlacement
Evangelink Jun 6, 2019
35832d8
Merge branch 'develop' into tcunderline_position
punker76 Jun 7, 2019
73130ad
XamlStyler again
punker76 Jun 7, 2019
2582430
New behavior Underline Position also for MetroTabControl
punker76 Jun 7, 2019
9bc55c3
Fix wrong RelativeSource binding to UnderlinePlacement for Controls.A…
punker76 Jun 7, 2019
7efbaea
Delete this unnecessary file doublet MetroTabControl
punker76 Jun 8, 2019
eb26b87
Fix usage of the new feature UnderlinePlacement for TabControl
punker76 Jun 8, 2019
daa3b21
Improve TabControl samples
punker76 Jun 8, 2019
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Windows.Controls;
using System;
using System.Collections;
using System.Windows.Controls;
using MahApps.Metro.Controls;

namespace MetroDemo.ExampleViews
Expand All @@ -12,13 +14,15 @@ public partial class TabControlExamples : UserControl
{
public TabControlExamples()
{
InitializeComponent();
this.InitializeComponent();
}

private void MetroTabControl_TabItemClosingEvent(object sender, BaseMetroTabControl.TabItemClosingEventArgs e)
{
if (e.ClosingTabItem.Header.ToString().StartsWith("sizes"))
{
e.Cancel = true;
}
}

private void TextBlock_OnLoaded(object sender, RoutedEventArgs e)
Expand All @@ -28,4 +32,16 @@ private void TextBlock_OnLoaded(object sender, RoutedEventArgs e)
textBlock.SetCurrentValue(TextBlock.TextProperty, (int.Parse(textBlock.Text) + 1).ToString());
}
}
}

public static class DockHelper
{
public static IEnumerable GetDockValues()
{
yield return null;
foreach (var dockValue in Enum.GetValues(typeof(Dock)))
{
yield return dockValue;
}
}
}
}
26 changes: 25 additions & 1 deletion src/MahApps.Metro/Controls/Helper/TabControlHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum UnderlinedType
public static class TabControlHelper
{
/// Sets the Style and Template property to null.
///
///
/// Removing a TabItem in code behind can produce such nasty output
/// System.Windows.Data Warning: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.TabControl', AncestorLevel='1''. BindingExpression:Path=Background; DataItem=null; target element is 'TabItem' (Name=''); target property is 'Background' (type 'Brush')
/// or
Expand Down Expand Up @@ -270,5 +270,29 @@ public static void SetTransition(DependencyObject obj, TransitionType value)
{
obj.SetValue(TransitionProperty, value);
}



/// <summary>
/// Defines the position of the <see cref="TabItem"/> Underline
/// </summary>

public static readonly DependencyProperty UnderlinePlacementProperty =
DependencyProperty.RegisterAttached("UnderlinePlacement",
typeof(Dock?),
typeof(TabControlHelper),
new PropertyMetadata(null));

[Category(AppName.MahApps)]
[AttachedPropertyBrowsableForType(typeof(TabControl))]
public static Dock? GetUnderlinePlacement(UIElement element)
{
return (Dock?)element.GetValue(UnderlinePlacementProperty);
}

public static void SetUnderlinePlacement(UIElement element, Dock? value)
{
element.SetValue(UnderlinePlacementProperty, value);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@
<Trigger Property="TabStripPlacement" Value="Right">
<Setter Property="Template" Value="{StaticResource VerticalAnimatedSingleRowTabControl}" />
</Trigger>

</Style.Triggers>
</Style>
</ResourceDictionary>
Loading