Skip to content

Commit

Permalink
TabView: Make TabViewItem consume the TabViewItemHeaderForeground the…
Browse files Browse the repository at this point in the history
…me resource (#2348)

* Make ContentPresenter consume the resource

* Set a tab as testing tab

* Add test
  • Loading branch information
Felix-Dev authored May 18, 2020
1 parent e34b0f0 commit b06204c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
14 changes: 14 additions & 0 deletions dev/TabView/InteractionTests/TabViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,20 @@ public void ScrollButtonToolTipTest()
}
}

[TestMethod]
public void VerifyTabViewItemHeaderForegroundResource()
{
using (var setup = new TestSetupHelper("TabView Tests"))
{
Button getSecondTabHeaderForegroundButton = FindElement.ByName<Button>("GetSecondTabHeaderForegroundButton");
getSecondTabHeaderForegroundButton.InvokeAndWait();

TextBlock secondTabHeaderForegroundTextBlock = FindElement.ByName<TextBlock>("SecondTabHeaderForegroundTextBlock");

Verify.AreEqual("#FF008000", secondTabHeaderForegroundTextBlock.DocumentText);
}
}

public void PressButtonAndVerifyText(String buttonName, String textBlockName, String expectedText)
{
Button button = FindElement.ByName<Button>(buttonName);
Expand Down
1 change: 1 addition & 0 deletions dev/TabView/TabView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@
ContentTransitions="{TemplateBinding ContentTransitions}"
FontWeight="{TemplateBinding FontWeight}"
FontSize="{ThemeResource TabViewItemHeaderFontSize}"
Foreground="{ThemeResource TabViewItemHeaderForeground}"
OpticalMarginAlignment="TrimSideBearings"
HighContrastAdjustment="None" />

Expand Down
9 changes: 9 additions & 0 deletions dev/TabView/TestUI/TabViewPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@
<Button x:Name="GetScrollIncreaseButtonToolTipButton" AutomationProperties.Name="GetScrollIncreaseButtonToolTipButton" Content="TooltipScrollIncreaseButton" Click="GetScrollIncreaseButtonToolTipButton_Click"/>
<TextBlock x:Name="ScrollIncreaseButtonToolTipTextBlock" AutomationProperties.Name="ScrollIncreaseButtonToolTipTextBlock" Margin="4,0,0,0" Text=""/>
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0,0,0,8">
<Button x:Name="GetSecondTabHeaderForegroundButton" AutomationProperties.Name="GetSecondTabHeaderForegroundButton" Content="SecondTabHeaderForeground" Click="GetSecondTabHeaderForegroundButton_Click" />
<TextBlock x:Name="SecondTabHeaderForegroundTextBlock" AutomationProperties.Name="SecondTabHeaderForegroundTextBlock" Margin="4,0,0,0" Text=""/>
</StackPanel>
</StackPanel>

<Grid Grid.Column="1">
Expand Down Expand Up @@ -153,6 +158,10 @@
</controls:TabViewItem>

<controls:TabViewItem x:Name="SecondTab" Header="SecondTab" IsClosable="True">
<controls:TabViewItem.Resources>
<!-- Do not remove or change this! We are verifying this resource in a TabView InteractionTest. -->
<SolidColorBrush x:Key="TabViewItemHeaderForeground" Color="#FF008000" />
</controls:TabViewItem.Resources>
<controls:TabViewItem.IconSource>
<controls:SymbolIconSource Symbol="Shop"/>
</controls:TabViewItem.IconSource>
Expand Down
9 changes: 9 additions & 0 deletions dev/TabView/TestUI/TabViewPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,5 +415,14 @@ private void GetScrollIncreaseButtonToolTipButton_Click(object sender, RoutedEve
GetToolTipStringForUIElement(scrollIncreaseButton, ScrollIncreaseButtonToolTipTextBlock);
}
}

private void GetSecondTabHeaderForegroundButton_Click(object sender, RoutedEventArgs e)
{
if (FindVisualChildByName(SecondTab, "ContentPresenter") is ContentPresenter presenter
&& presenter.Foreground is SolidColorBrush brush)
{
SecondTabHeaderForegroundTextBlock.Text = brush.Color.ToString();
}
}
}
}

0 comments on commit b06204c

Please sign in to comment.