Skip to content

Commit 1bf1c8c

Browse files
authored
Pane Title is completely not visible in HC mode (#177)
* The pane title was being obscured by the pane toggle button. Outside of High Contrast that works fine... but in HC the button background is opaque. I could split out resources for that background to be transparent in HC... but fundamentally this is a weird layout to have the text _under_ the button. It means that any non-transparent background is actually doing the wrong thing with regards to layering on the text. So... I opted to change how this was built. The key to fixing this was to have the button support both an icon and a piece of text. Since the control already has a forked template this was pretty easy. Move the ContentPresenter to be to the right of the fixed icon and update the layout accordingly. The search button was riding on the same style as the toggle button for some reason. That wasn't really necessary, as with a couple tweaks it could use a lightly styled standard Button template.
1 parent 635be03 commit 1bf1c8c

File tree

3 files changed

+47
-29
lines changed

3 files changed

+47
-29
lines changed

dev/NavigationView/NavigationView.xaml

+10-10
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,15 @@
163163
Style="{TemplateBinding PaneToggleButtonStyle}"
164164
AutomationProperties.LandmarkType="Navigation"
165165
Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.PaneToggleButtonVisibility}"
166-
VerticalAlignment="Top"/>
166+
VerticalAlignment="Top">
167+
<TextBlock
168+
x:Name="PaneTitleTextBlock"
169+
Grid.Column="0"
170+
Text="{TemplateBinding PaneTitle}"
171+
HorizontalAlignment="Left"
172+
VerticalAlignment="Center"
173+
Style="{StaticResource NavigationViewItemHeaderTextStyle}"/>
174+
</Button>
167175
</Grid>
168176
</Grid>
169177

@@ -346,18 +354,10 @@
346354

347355
<Grid Grid.Row="2" Height="{StaticResource PaneToggleButtonHeight}">
348356
<Grid.ColumnDefinitions>
349-
<ColumnDefinition Width="Auto"/>
357+
<ColumnDefinition Width="{ThemeResource PaneToggleButtonWidth}"/>
350358
<ColumnDefinition Width="*"/>
351359
</Grid.ColumnDefinitions>
352360

353-
<TextBlock
354-
x:Name="PaneTitleTextBlock"
355-
Grid.Column="0"
356-
Text="{TemplateBinding PaneTitle}"
357-
HorizontalAlignment="Left"
358-
VerticalAlignment="Center"
359-
Style="{StaticResource NavigationViewItemHeaderTextStyle}"/>
360-
361361
<ContentControl
362362
x:Name="PaneHeaderContentBorder"
363363
IsTabStop="False"

dev/NavigationView/NavigationView_rs1_themeresources.xaml

+36-18
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,23 @@
212212
<Setter Property="Background" Value="{ThemeResource NavigationViewItemBackground}" />
213213
<Setter Property="Foreground" Value="{ThemeResource NavigationViewItemForeground}" />
214214
<Setter Property="BorderThickness" Value="{ThemeResource NavigationViewToggleBorderThickness}" />
215-
<Setter Property="Content" Value="&#xE700;" />
216215
<Setter Property="Template">
217216
<Setter.Value>
218217
<ControlTemplate TargetType="Button">
219218
<Grid
220219
x:Name="LayoutRoot"
220+
MinWidth="{TemplateBinding MinWidth}"
221221
Height="{TemplateBinding MinHeight}"
222222
Margin="{TemplateBinding Padding}"
223223
Background="{TemplateBinding Background}"
224224
HorizontalAlignment="Stretch">
225+
<Grid.ColumnDefinitions>
226+
<ColumnDefinition Width="{ThemeResource PaneToggleButtonWidth}"/>
227+
<ColumnDefinition Width="*"/>
228+
</Grid.ColumnDefinitions>
229+
<Grid.RowDefinitions>
230+
<RowDefinition Height="{ThemeResource PaneToggleButtonHeight}"/>
231+
</Grid.RowDefinitions>
225232

226233
<VisualStateManager.VisualStateGroups>
227234
<VisualStateGroup x:Name="CommonStates">
@@ -271,36 +278,47 @@
271278
</VisualStateGroup>
272279
</VisualStateManager.VisualStateGroups>
273280

274-
<Grid Width="{TemplateBinding MinWidth}" HorizontalAlignment="Left">
275-
<Viewbox
276-
x:Name="IconHost"
277-
Width="16"
278-
Height="16"
279-
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
280-
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
281-
AutomationProperties.AccessibilityView="Raw">
281+
<Viewbox
282+
x:Name="IconHost"
283+
Width="16"
284+
Height="16"
285+
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
286+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
287+
AutomationProperties.AccessibilityView="Raw">
282288

283-
<ContentPresenter
284-
x:Name="ContentPresenter"
285-
Content="{TemplateBinding Content}"
286-
FontSize="{TemplateBinding FontSize}"
287-
AutomationProperties.AccessibilityView="Raw"/>
288-
</Viewbox>
289-
</Grid>
289+
<TextBlock
290+
x:Name="Icon"
291+
Text="&#xE700;"
292+
FontSize="{TemplateBinding FontSize}"
293+
AutomationProperties.AccessibilityView="Raw"/>
294+
295+
</Viewbox>
296+
297+
<ContentPresenter
298+
x:Name="ContentPresenter"
299+
VerticalContentAlignment="Center"
300+
Content="{TemplateBinding Content}"
301+
FontSize="{TemplateBinding FontSize}"
302+
Grid.Column="1"/>
290303

291304
<Border
292305
x:Name="RevealBorder"
293306
BorderBrush="{TemplateBinding BorderBrush}"
294-
BorderThickness="{TemplateBinding BorderThickness}" />
307+
BorderThickness="{TemplateBinding BorderThickness}"
308+
Grid.ColumnSpan="2"/>
295309
</Grid>
296310
</ControlTemplate>
297311
</Setter.Value>
298312
</Setter>
299313
</Style>
300314

301-
<Style x:Key="NavigationViewPaneSearchButtonStyle" BasedOn="{StaticResource PaneToggleButtonStyle}" TargetType="Button">
315+
<Style x:Key="NavigationViewPaneSearchButtonStyle" TargetType="Button">
302316
<Setter Property="MinHeight" Value="40"/>
303317
<Setter Property="Content" Value="&#xE11A;"/>
318+
<Setter Property="FontFamily" Value="Segoe MDL2 Assets" />
319+
<Setter Property="BorderThickness" Value="{ThemeResource NavigationViewToggleBorderThickness}" />
320+
<Setter Property="Background" Value="{ThemeResource NavigationViewItemBackground}" />
321+
<Setter Property="Foreground" Value="{ThemeResource NavigationViewItemForeground}" />
304322
</Style>
305323

306324
<Style x:Key="NavigationViewOverflowButtonStyleWhenPaneOnTop" TargetType="Button">

dev/NavigationView/TestUI/NavigationViewPage.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ private void NavView_PaneOpened(NavigationView sender, object args)
440440

441441
private void ChangePaneTitle_Click(object sender, RoutedEventArgs e)
442442
{
443-
NavView.PaneTitle = "";
443+
NavView.PaneTitle = (String.IsNullOrEmpty(NavView.PaneTitle) ? "NavView Test" : "");
444444
}
445445

446446
private void CopyVolumeToolTipButton_Click(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)