A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

208 lines
12 KiB

<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Width="400" Height="600">
<NavigationPage />
</Border>
</Design.PreviewWith>
<StreamGeometry x:Key="NavigationPageMenuIcon">M3 17h18a1 1 0 0 1 .117 1.993L21 19H3a1 1 0 0 1-.117-1.993L3 17h18H3Zm0-6 18-.002a1 1 0 0 1 .117 1.993l-.117.007L3 13a1 1 0 0 1-.117-1.993L3 11l18-.002L3 11Zm0-6h18a1 1 0 0 1 .117 1.993L21 7H3a1 1 0 0 1-.117-1.993L3 5h18H3Z</StreamGeometry>
<StreamGeometry x:Key="NavigationPageBackIcon">M12.7347,4.20949 C13.0332,3.92233 13.508,3.93153 13.7952,4.23005 C14.0823,4.52857 14.0731,5.00335 13.7746,5.29051 L5.50039,13.25 L24.2532,13.25 C24.6674,13.25 25.0032,13.5858 25.0032,13.9999982 C25.0032,14.4142 24.6674,14.75 24.2532,14.75 L5.50137,14.75 L13.7746,22.7085 C14.0731,22.9957 14.0823,23.4705 13.7952,23.769 C13.508,24.0675 13.0332,24.0767 12.7347,23.7896 L3.30673,14.7202 C2.89776,14.3268 2.89776,13.6723 3.30673,13.2788 L12.7347,4.20949 Z</StreamGeometry>
<SolidColorBrush x:Key="NavigationBarBackground" Color="{DynamicResource SystemChromeMediumColor}" />
<SolidColorBrush x:Key="NavigationBarForeground" Color="{DynamicResource SystemBaseMediumColor}" />
<ControlTheme x:Key="{x:Type NavigationPage}" TargetType="NavigationPage">
<!-- Transparent keeps the hit-test surface active for the back-swipe gesture edge area. -->
<Setter Property="Background" Value="Transparent" />
<Setter Property="PageTransition">
<Setter.Value>
<PageSlide Duration="0:0:0.3" Orientation="Horizontal" FillMode="Forward" />
</Setter.Value>
</Setter>
<Setter Property="ModalTransition">
<Setter.Value>
<PageSlide Duration="0:0:0.25" Orientation="Vertical" FillMode="Forward" />
</Setter.Value>
</Setter>
<Setter Property="Template">
<ControlTemplate>
<!-- ClipToBounds prevents slide animations bleeding outside the control bounds. -->
<Panel ClipToBounds="True">
<DockPanel>
<!-- Reserves nav-bar height in Inset mode. Invisible in Overlay mode. -->
<Border Name="PART_NavBarSpacer"
Height="{TemplateBinding EffectiveBarHeight}"
IsVisible="False"
DockPanel.Dock="Top" />
<ContentPresenter Name="PART_BottomCommandBar"
DockPanel.Dock="Bottom"
HorizontalContentAlignment="Stretch"
Background="{TemplateBinding Background}"
Content="{Binding CurrentPage?.(NavigationPage.BottomCommandBar), RelativeSource={RelativeSource TemplatedParent}, FallbackValue={x:Null}}" />
<!-- Back and front presenters enable slide transitions without Control recycling. -->
<Grid Name="PART_ContentHost"
Background="{TemplateBinding Background}"
ClipToBounds="True">
<ContentPresenter Name="PART_PageBackPresenter"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
<ContentPresenter Name="PART_PagePresenter"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
</Grid>
</DockPanel>
<!-- Navigation bar floats above content (ZIndex=1). -->
<Border Name="PART_NavigationBar"
ZIndex="1"
VerticalAlignment="Top"
ClipToBounds="True"
Height="{TemplateBinding EffectiveBarHeight}">
<Grid Margin="12,0,0,0" ColumnDefinitions="Auto, *, Auto">
<Grid.Styles>
<Style Selector="Button#PART_BackButton /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="Transparent" />
<Setter Property="CornerRadius" Value="4" />
</Style>
<Style Selector="Button#PART_BackButton:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SubtleFillColorSecondaryBrush}" />
</Style>
<Style Selector="Button#PART_BackButton:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SubtleFillColorTertiaryBrush}" />
</Style>
<Style Selector="Button#PART_BackButton:disabled">
<Setter Property="Opacity" Value="0.4" />
</Style>
<Style Selector="Button#PART_BackButton:focus-visible /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="BorderThickness" Value="2" />
<Setter Property="CornerRadius" Value="4" />
</Style>
<Style Selector="Button:disabled /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="Transparent" />
</Style>
<Style Selector="Button#PART_OverflowButton /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="Transparent" />
<Setter Property="CornerRadius" Value="0" />
</Style>
<Style Selector="Button#PART_OverflowButton:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SubtleFillColorSecondaryBrush}" />
</Style>
<Style Selector="Button#PART_OverflowButton:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SubtleFillColorTertiaryBrush}" />
</Style>
</Grid.Styles>
<Button x:Name="PART_BackButton"
Grid.Column="0"
Background="Transparent"
Foreground="{DynamicResource NavigationBarForeground}"
IsVisible="{TemplateBinding IsBackButtonEffectivelyVisible}"
VerticalAlignment="Stretch"
Padding="8,0"
ToolTip.Tip="{x:Null}">
<Panel Background="Transparent">
<Path Data="{DynamicResource NavigationPageBackIcon}"
Fill="{DynamicResource NavigationBarForeground}"
Width="24"
Height="24"
Stretch="Uniform"
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsVisible="{Binding CurrentPage?.(NavigationPage.BackButtonContent), RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static ObjectConverters.IsNull}, FallbackValue=False}" />
<ContentPresenter
Content="{Binding CurrentPage?.(NavigationPage.BackButtonContent), RelativeSource={RelativeSource TemplatedParent}, FallbackValue={x:Null}}"
IsVisible="{Binding CurrentPage?.(NavigationPage.BackButtonContent), RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static ObjectConverters.IsNotNull}, FallbackValue=False}"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</Panel>
</Button>
<ContentPresenter Name="PART_Header"
Grid.Column="1"
FontSize="20"
Foreground="{DynamicResource NavigationBarForeground}"
Content="{Binding CurrentPage?.Header, RelativeSource={RelativeSource TemplatedParent}, FallbackValue={x:Null}}"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Margin="0,0,12,0" />
<ContentPresenter Name="PART_TopCommandBar"
Grid.Column="2"
HorizontalAlignment="Right"
VerticalContentAlignment="Stretch"
Foreground="{DynamicResource NavigationBarForeground}"
Content="{Binding CurrentPage?.(NavigationPage.TopCommandBar), RelativeSource={RelativeSource TemplatedParent}, FallbackValue={x:Null}}">
<ContentPresenter.Styles>
<Style Selector="CommandBar">
<Setter Property="Background" Value="Transparent" />
<Setter Property="MinHeight" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="VerticalAlignment" Value="Stretch" />
</Style>
<Style Selector="AppBarButton">
<Setter Property="MinHeight" Value="0" />
<Setter Property="Padding" Value="8,0" />
</Style>
<Style Selector="AppBarToggleButton">
<Setter Property="MinHeight" Value="0" />
<Setter Property="Padding" Value="8,0" />
</Style>
<Style Selector="Button#PART_OverflowButton">
<Setter Property="MinHeight" Value="0" />
<Setter Property="Padding" Value="8,0" />
</Style>
</ContentPresenter.Styles>
</ContentPresenter>
</Grid>
</Border>
<!-- Nav-bar shadow gradient. Margin.Top is set from code to match EffectiveBarHeight. -->
<Border Name="PART_NavBarShadow"
ZIndex="1"
VerticalAlignment="Top"
IsVisible="False"
Height="4"
IsHitTestVisible="False">
<Border.Background>
<LinearGradientBrush StartPoint="0%,0%" EndPoint="0%,100%">
<GradientStop Color="#0C000000" Offset="0" />
<GradientStop Color="#00000000" Offset="1" />
</LinearGradientBrush>
</Border.Background>
</Border>
<!-- Modal overlay: ZIndex=99 holds the static layer during transitions; ZIndex=100 is the animating modal. -->
<ContentPresenter Name="PART_ModalBackPresenter"
ZIndex="99"
IsVisible="False"
Background="{TemplateBinding Background}" />
<ContentPresenter Name="PART_ModalPresenter"
ZIndex="100"
IsVisible="False"
Background="{TemplateBinding Background}" />
</Panel>
</ControlTemplate>
</Setter>
<!-- Default nav bar background, overridable via a more-specific style selector -->
<Style Selector="^ /template/ Border#PART_NavigationBar">
<Setter Property="Background" Value="{DynamicResource NavigationBarBackground}" />
</Style>
<!-- :nav-bar-inset: spacer reserves nav-bar height so content is pushed below -->
<Style Selector="^:nav-bar-inset /template/ Border#PART_NavBarSpacer">
<Setter Property="IsVisible" Value="True" />
</Style>
<!-- :nav-bar-compact: collapse CommandBar labels when bar is too short -->
<Style Selector="^:nav-bar-compact /template/ ContentPresenter#PART_TopCommandBar CommandBar">
<Setter Property="DefaultLabelPosition" Value="Collapsed" />
</Style>
</ControlTheme>
</ResourceDictionary>