feat: add dismiss Button.

This commit is contained in:
Zhang Dian 2024-11-24 22:46:36 +08:00
parent 7ac603b18e
commit ed6b8c7469
4 changed files with 44 additions and 37 deletions

View File

@ -112,23 +112,12 @@
<ListBox
Grid.Row="1"
ItemsSource="{Binding Songs}" />
<ToggleSwitch
<ToggleButton
Grid.Row="2"
Theme="{DynamicResource ButtonToggleSwitch}"
Theme="{DynamicResource SplitViewToggleButton}"
HorizontalAlignment="Left"
IsChecked="{Binding #SplitView.IsPaneOpen}">
<ToggleSwitch.OnContent>
<PathIcon
Width="16"
Height="16"
Data="{StaticResource NavigationMenuExpandIconGlyph}" />
</ToggleSwitch.OnContent>
<ToggleSwitch.OffContent>
<PathIcon
Width="16"
Height="16"
Data="{StaticResource NavigationMenuExpandIconGlyph}" />
</ToggleSwitch.OffContent>
</ToggleSwitch>
</ToggleButton>
</Grid>
</SplitView.Pane>

View File

@ -1,6 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme x:Key="NavigationTab" TargetType="TabControl">
<Setter Property="TabControl.Template">
<Setter Property="Template">
<ControlTemplate TargetType="TabControl">
<Border
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
@ -10,7 +10,10 @@
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<DockPanel>
<ScrollViewer DockPanel.Dock="Left" VerticalScrollBarVisibility="Auto">
<ScrollViewer
DockPanel.Dock="Left"
Name="PART_ScrollViewer"
VerticalScrollBarVisibility="Auto">
<Panel DockPanel.Dock="{TemplateBinding TabStripPlacement}">
<ItemsPresenter Name="PART_ItemsPresenter">
<ItemsPresenter.ItemsPanel>
@ -19,7 +22,8 @@
</ItemsPanelTemplate>
</ItemsPresenter.ItemsPanel>
</ItemsPresenter>
<Border Name="PART_BorderSeparator" Background="{DynamicResource TabItemLinePipePressedBorderBrush}" />
<Border Name="PART_BorderSeparator"
Background="{DynamicResource TabItemLinePipePressedBorderBrush}" />
</Panel>
</ScrollViewer>
<ContentPresenter
@ -38,5 +42,8 @@
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Left" />
</Style>
<Style Selector="^.Dismiss /template/ ScrollViewer#PART_ScrollViewer">
<Setter Property="IsVisible" Value="False" />
</Style>
</ControlTheme>
</ResourceDictionary>
</ResourceDictionary>

View File

@ -1,18 +1,26 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme x:Key="SplitViewToggleButton" TargetType="ToggleButton">
<Setter Property="ToggleButton.Template">
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="Padding" Value="8" />
<Setter Property="Foreground" Value="{DynamicResource ButtonDefaultTertiaryForeground}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="CornerRadius" Value="3" />
<Setter Property="Content"
Value="M5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2ZM6 4C5.44772 4 5 4.44772 5 5V19C5 19.5523 5.44772 20 6 20H9C9.55229 20 10 19.5523 10 19V5C10 4.44772 9.55229 4 9 4H6Z" />
<Setter Property="Template">
<ControlTemplate TargetType="ToggleButton">
<Border
Name="Background"
Padding="8"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
CornerRadius="3">
CornerRadius="{TemplateBinding CornerRadius}">
<PathIcon
Name="Icon"
Width="16"
Height="16"
Data="M5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2ZM6 4C5.44772 4 5 4.44772 5 5V19C5 19.5523 5.44772 20 6 20H9C9.55229 20 10 19.5523 10 19V5C10 4.44772 9.55229 4 9 4H6Z"
Foreground="{DynamicResource ButtonDefaultTertiaryForeground}" />
Theme="{DynamicResource InnerPathIcon}"
Data="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}" />
</Border>
</ControlTemplate>
</Setter>
@ -23,4 +31,4 @@
<Setter Property="Background" Value="{DynamicResource ButtonDefaultPressedBackground}" />
</Style>
</ControlTheme>
</ResourceDictionary>
</ResourceDictionary>

View File

@ -21,27 +21,29 @@
</UserControl.Resources>
<Grid RowDefinitions="Auto, *">
<Border
Grid.Row="0"
Margin="8"
Padding="12,4"
Theme="{DynamicResource CardBorder}">
<Grid VerticalAlignment="Center" ColumnDefinitions="*, Auto">
<StackPanel Grid.Column="0" Orientation="Horizontal">
<TextBlock
<Panel>
<StackPanel Orientation="Horizontal" Spacing="8">
<ToggleButton
Name="ExpandButton"
Theme="{DynamicResource SplitViewToggleButton}" />
<SelectableTextBlock
VerticalAlignment="Center"
Classes="H6"
Text="Semi Avalonia"
Theme="{DynamicResource TitleTextBlock}" />
<TextBlock
Margin="8,0"
Theme="{DynamicResource TitleSelectableTextBlock}" />
<SelectableTextBlock
VerticalAlignment="Center"
Text="/" />
<TextBlock
Margin="8,0"
<SelectableTextBlock
VerticalAlignment="Center"
Classes="Secondary"
Text="{ReflectionBinding #tab.SelectedItem.Header}" />
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button
Click="OpenDocumentation"
Theme="{DynamicResource BorderlessButton}"
@ -102,7 +104,7 @@
</Button.Styles>
</Button>
</StackPanel>
</Grid>
</Panel>
</Border>
<TabControl
Name="tab"
@ -111,6 +113,7 @@
Padding="20,0,0,0"
HorizontalAlignment="Stretch"
TabStripPlacement="Left"
Classes.Dismiss="{Binding #ExpandButton.IsChecked}"
Theme="{DynamicResource NavigationTab}">
<TabItem Header="Overview">
<pages:Overview />