Skip to content

Commit 5df83b8

Browse files
authored
Fixing issue with tab control not showing its underline (#2646)
* Fixing issue with tab control not showing its underline * Fixing UI test location for snapshots
1 parent ca6ca58 commit 5df83b8

File tree

5 files changed

+61
-71
lines changed

5 files changed

+61
-71
lines changed

.github/actions/build-and-test/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ runs:
4040
uses: actions/upload-artifact@v2
4141
with:
4242
name: Screenshots-${{ github.run_number }}
43-
path: ${{ github.workspace }}/MaterialDesignThemes.UITests/bin/${{ inputs.buildConfiguration }}/net5.0-windows/Screenshots
43+
path: ${{ github.workspace }}/MaterialDesignThemes.UITests/bin/${{ inputs.buildConfiguration }}/net6.0-windows/Screenshots

MaterialDesignThemes.UITests/WPF/TabControls/TabControlTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.ComponentModel;
1+
using System.ComponentModel;
22
using System.Threading.Tasks;
33
using System.Windows.Controls;
44
using System.Windows.Media;
@@ -31,20 +31,24 @@ public async Task OnLoad_ThemeBrushesSet()
3131
<TabItem Header=""TAB 2"">
3232
<TextBlock Margin=""8"" Text=""PrimaryMid Tab 2"" />
3333
</TabItem>
34-
</TabControl> ");
34+
</TabControl>");
3535

3636
IVisualElement<TextBlock> textBlock = await tabControl.GetElement<TextBlock>(@"/TabItem[0]/TextBlock[0]");
37+
IVisualElement<Border> selectedTabBorder = await tabControl.GetElement<Border>(@"/TabItem[0]~SelectionHighlightBorder");
3738

3839
//Act
3940
Color? foreground = await textBlock.GetForegroundColor();
4041
Color? background = await textBlock.GetEffectiveBackground();
42+
Color? selectedTabUnderline = await selectedTabBorder.GetBorderBrushColor();
4143

4244
//Assert
4345
Assert.NotNull(foreground);
4446
Assert.NotNull(background);
4547

4648
MaterialDesignSpec.AssertContrastRatio(foreground.Value, background.Value, MaterialDesignSpec.MinimumContrastSmallText);
4749

50+
Assert.Equal(foreground, selectedTabUnderline);
51+
4852
recorder.Success();
4953
}
5054
}

MaterialDesignThemes.Wpf/ColorZone.cs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11
using System.Windows;
22
using System.Windows.Controls;
33

4-
namespace MaterialDesignThemes.Wpf
5-
{
4+
namespace MaterialDesignThemes.Wpf;
65

7-
/// <summary>
8-
/// User a colour zone to easily switch the background and foreground colours, from selected Material Design palette or custom ones.
9-
/// </summary>
10-
public class ColorZone : ContentControl
6+
/// <summary>
7+
/// User a colour zone to easily switch the background and foreground colours, from selected Material Design palette or custom ones.
8+
/// </summary>
9+
public class ColorZone : ContentControl
10+
{
11+
static ColorZone()
1112
{
12-
static ColorZone()
13-
{
14-
DefaultStyleKeyProperty.OverrideMetadata(typeof(ColorZone), new FrameworkPropertyMetadata(typeof(ColorZone)));
15-
}
13+
DefaultStyleKeyProperty.OverrideMetadata(typeof(ColorZone), new FrameworkPropertyMetadata(typeof(ColorZone)));
14+
}
1615

17-
public static readonly DependencyProperty ModeProperty = DependencyProperty.Register(
18-
nameof(Mode), typeof(ColorZoneMode), typeof(ColorZone), new PropertyMetadata(default(ColorZoneMode)));
16+
public static readonly DependencyProperty ModeProperty = DependencyProperty.Register(
17+
nameof(Mode), typeof(ColorZoneMode), typeof(ColorZone), new PropertyMetadata(default(ColorZoneMode)));
1918

20-
public ColorZoneMode Mode
21-
{
22-
get => (ColorZoneMode)GetValue(ModeProperty);
23-
set => SetValue(ModeProperty, value);
24-
}
19+
public ColorZoneMode Mode
20+
{
21+
get => (ColorZoneMode)GetValue(ModeProperty);
22+
set => SetValue(ModeProperty, value);
23+
}
2524

26-
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
27-
nameof(CornerRadius), typeof(CornerRadius), typeof(ColorZone), new PropertyMetadata(default(CornerRadius)));
25+
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
26+
nameof(CornerRadius), typeof(CornerRadius), typeof(ColorZone), new PropertyMetadata(default(CornerRadius)));
2827

29-
public CornerRadius CornerRadius
30-
{
31-
get => (CornerRadius)GetValue(CornerRadiusProperty);
32-
set => SetValue(CornerRadiusProperty, value);
33-
}
28+
public CornerRadius CornerRadius
29+
{
30+
get => (CornerRadius)GetValue(CornerRadiusProperty);
31+
set => SetValue(CornerRadiusProperty, value);
3432
}
3533
}
Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,34 @@
11
using System.Windows;
22
using System.Windows.Media;
33

4-
namespace MaterialDesignThemes.Wpf
4+
namespace MaterialDesignThemes.Wpf;
5+
6+
public static class ColorZoneAssist
57
{
6-
public static class ColorZoneAssist
7-
{
8-
public static readonly DependencyProperty ModeProperty = DependencyProperty.RegisterAttached(
9-
"Mode", typeof(ColorZoneMode), typeof(ColorZoneAssist), new FrameworkPropertyMetadata(default(ColorZoneMode), FrameworkPropertyMetadataOptions.Inherits));
10-
11-
public static void SetMode(DependencyObject element, ColorZoneMode value)
12-
{
13-
element.SetValue(ModeProperty, value);
14-
}
15-
16-
public static ColorZoneMode GetMode(DependencyObject element)
17-
{
18-
return (ColorZoneMode)element.GetValue(ModeProperty);
19-
}
20-
21-
public static readonly DependencyProperty BackgroundProperty = DependencyProperty.RegisterAttached(
22-
"Background", typeof(Brush), typeof(ColorZoneAssist), new FrameworkPropertyMetadata(default(Brush)));
23-
24-
public static void SetBackground(DependencyObject element, Brush value)
25-
{
26-
element.SetValue(BackgroundProperty, value);
27-
}
28-
29-
public static Brush GetBackground(DependencyObject element)
30-
{
31-
return (Brush)element.GetValue(BackgroundProperty);
32-
}
33-
34-
public static readonly DependencyProperty ForegroundProperty = DependencyProperty.RegisterAttached(
35-
"Foreground", typeof(Brush), typeof(ColorZoneAssist), new FrameworkPropertyMetadata(default(Brush)));
36-
37-
public static void SetForeground(DependencyObject element, Brush value)
38-
{
39-
element.SetValue(ForegroundProperty, value);
40-
}
41-
42-
public static Brush GetForeground(DependencyObject element)
43-
{
44-
return (Brush)element.GetValue(ForegroundProperty);
45-
}
46-
}
8+
public static readonly DependencyProperty ModeProperty = DependencyProperty.RegisterAttached(
9+
"Mode", typeof(ColorZoneMode), typeof(ColorZoneAssist), new FrameworkPropertyMetadata(default(ColorZoneMode), FrameworkPropertyMetadataOptions.Inherits));
10+
11+
public static void SetMode(DependencyObject element, ColorZoneMode value)
12+
=> element.SetValue(ModeProperty, value);
13+
14+
public static ColorZoneMode GetMode(DependencyObject element)
15+
=> (ColorZoneMode)element.GetValue(ModeProperty);
16+
17+
public static readonly DependencyProperty BackgroundProperty = DependencyProperty.RegisterAttached(
18+
"Background", typeof(Brush), typeof(ColorZoneAssist), new FrameworkPropertyMetadata(default(Brush)));
19+
20+
public static void SetBackground(DependencyObject element, Brush value)
21+
=> element.SetValue(BackgroundProperty, value);
22+
23+
public static Brush GetBackground(DependencyObject element)
24+
=> (Brush)element.GetValue(BackgroundProperty);
25+
26+
public static readonly DependencyProperty ForegroundProperty = DependencyProperty.RegisterAttached(
27+
"Foreground", typeof(Brush), typeof(ColorZoneAssist), new FrameworkPropertyMetadata(default(Brush)));
28+
29+
public static void SetForeground(DependencyObject element, Brush value)
30+
=> element.SetValue(ForegroundProperty, value);
31+
32+
public static Brush GetForeground(DependencyObject element)
33+
=> (Brush)element.GetValue(ForegroundProperty);
4734
}

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TabControl.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@
228228
HorizontalAlignment="Stretch"
229229
VerticalAlignment="Stretch"
230230
Focusable="False"
231-
Mode="{TemplateBinding wpf:ColorZoneAssist.Mode}">
231+
Mode="{TemplateBinding wpf:ColorZoneAssist.Mode}"
232+
x:Name="ColorZoneHeader">
232233
<wpf:Ripple
233234
x:Name="contentPresenter"
234235
Padding="{TemplateBinding Padding}"
@@ -250,7 +251,7 @@
250251
</wpf:ColorZone>
251252
<Border
252253
x:Name="SelectionHighlightBorder"
253-
BorderBrush="{TemplateBinding wpf:ColorZoneAssist.Foreground}"
254+
BorderBrush="{Binding Path=Foreground, ElementName=ColorZoneHeader}"
254255
BorderThickness="0,0,0,2"
255256
RenderTransformOrigin="0.5,0.5"
256257
Visibility="Hidden">

0 commit comments

Comments
 (0)