mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-05 00:37:17 +08:00
feat: Add Splitview.
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/ScrollViewer.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/Slider.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/SplitButton.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/SplitView.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/TabControl.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/TabItem.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/TabStrip.axaml" />
|
||||
|
||||
251
src/Semi.Avalonia/Controls/SplitView.axaml
Normal file
251
src/Semi.Avalonia/Controls/SplitView.axaml
Normal file
@@ -0,0 +1,251 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="using:System">
|
||||
<!-- Add Resources Here -->
|
||||
|
||||
<ControlTheme x:Key="{x:Type SplitView}" TargetType="SplitView">
|
||||
<Setter Property="OpenPaneLength" Value="{DynamicResource SplitViewOpenPaneThemeLength}" />
|
||||
<Setter Property="CompactPaneLength" Value="{DynamicResource SplitViewCompactPaneThemeLength}" />
|
||||
<Setter Property="PaneBackground" Value="White" />
|
||||
|
||||
<Style Selector="^:left">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="SplitView">
|
||||
<Grid Name="Container" Background="{TemplateBinding Background}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<!-- why is this throwing a binding error? -->
|
||||
<ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.PaneColumnGridLength}" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Panel
|
||||
Name="PART_PaneRoot"
|
||||
HorizontalAlignment="Left"
|
||||
Background="{TemplateBinding PaneBackground}"
|
||||
ClipToBounds="True"
|
||||
ZIndex="100">
|
||||
<ContentPresenter
|
||||
x:Name="PART_PanePresenter"
|
||||
Content="{TemplateBinding Pane}"
|
||||
ContentTemplate="{TemplateBinding PaneTemplate}" />
|
||||
<Rectangle
|
||||
Name="HCPaneBorder"
|
||||
Width="1"
|
||||
HorizontalAlignment="Right"
|
||||
Fill="{DynamicResource SplitViewSeparatorBackground}" />
|
||||
</Panel>
|
||||
|
||||
<Panel Name="ContentRoot">
|
||||
<ContentPresenter
|
||||
x:Name="PART_ContentPresenter"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
||||
<Rectangle
|
||||
Name="LightDismissLayer"
|
||||
Fill="Transparent"
|
||||
IsVisible="False" />
|
||||
</Panel>
|
||||
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:overlay">
|
||||
<Style Selector="^ /template/ Panel#PART_PaneRoot">
|
||||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
<Setter Property="Grid.Column" Value="0" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Panel#ContentRoot">
|
||||
<Setter Property="Grid.Column" Value="1" />
|
||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:compactinline">
|
||||
<Style Selector="^ /template/ Panel#PART_PaneRoot">
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
<Setter Property="Grid.Column" Value="0" />
|
||||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Panel#ContentRoot">
|
||||
<Setter Property="Grid.Column" Value="1" />
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:compactoverlay">
|
||||
<Style Selector="^ /template/ Panel#PART_PaneRoot">
|
||||
<!-- ColumnSpan should be 2 -->
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
<Setter Property="Grid.Column" Value="0" />
|
||||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Panel#ContentRoot">
|
||||
<Setter Property="Grid.Column" Value="1" />
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:inline">
|
||||
<Style Selector="^ /template/ Panel#PART_PaneRoot">
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
<Setter Property="Grid.Column" Value="0" />
|
||||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Panel#ContentRoot">
|
||||
<Setter Property="Grid.Column" Value="1" />
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
</Style>
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:right">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Grid Name="Container" Background="{TemplateBinding Background}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.PaneColumnGridLength}" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Panel
|
||||
Name="PART_PaneRoot"
|
||||
HorizontalAlignment="Right"
|
||||
Background="{TemplateBinding PaneBackground}"
|
||||
ClipToBounds="True"
|
||||
ZIndex="100">
|
||||
<ContentPresenter
|
||||
x:Name="PART_PanePresenter"
|
||||
Content="{TemplateBinding Pane}"
|
||||
ContentTemplate="{TemplateBinding PaneTemplate}" />
|
||||
<Rectangle
|
||||
Name="HCPaneBorder"
|
||||
Width="1"
|
||||
HorizontalAlignment="Left"
|
||||
Fill="{DynamicResource SplitViewSeparatorBackground}" />
|
||||
</Panel>
|
||||
|
||||
<Panel Name="ContentRoot">
|
||||
<ContentPresenter
|
||||
x:Name="PART_ContentPresenter"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
||||
<Rectangle Name="LightDismissLayer" />
|
||||
</Panel>
|
||||
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:overlay">
|
||||
<Style Selector="^ /template/ Panel#PART_PaneRoot">
|
||||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
|
||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
||||
<Setter Property="Grid.Column" Value="1" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Panel#ContentRoot">
|
||||
<Setter Property="Grid.Column" Value="0" />
|
||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:compactinline">
|
||||
<Style Selector="^ /template/ Panel#PART_PaneRoot">
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
<Setter Property="Grid.Column" Value="1" />
|
||||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Panel#ContentRoot">
|
||||
<Setter Property="Grid.Column" Value="0" />
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:compactoverlay">
|
||||
<Style Selector="^ /template/ Panel#PART_PaneRoot">
|
||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
||||
<Setter Property="Grid.Column" Value="1" />
|
||||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Panel#ContentRoot">
|
||||
<Setter Property="Grid.Column" Value="0" />
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:inline">
|
||||
<Style Selector="^ /template/ Panel#PART_PaneRoot">
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
<Setter Property="Grid.Column" Value="1" />
|
||||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Panel#ContentRoot">
|
||||
<Setter Property="Grid.Column" Value="0" />
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
</Style>
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:open">
|
||||
<Style Selector="^ /template/ Panel#PART_PaneRoot">
|
||||
<Setter Property="Transitions">
|
||||
<Transitions>
|
||||
<DoubleTransition
|
||||
Easing="{StaticResource SplitViewPaneAnimationEasing}"
|
||||
Property="Width"
|
||||
Duration="{StaticResource SplitViewPaneAnimationOpenDuration}" />
|
||||
</Transitions>
|
||||
</Setter>
|
||||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=OpenPaneLength}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Rectangle#LightDismissLayer">
|
||||
<Setter Property="Transitions">
|
||||
<Transitions>
|
||||
<DoubleTransition
|
||||
Easing="{StaticResource SplitViewPaneAnimationEasing}"
|
||||
Property="Opacity"
|
||||
Duration="{StaticResource SplitViewPaneAnimationOpenDuration}" />
|
||||
</Transitions>
|
||||
</Setter>
|
||||
<Setter Property="Opacity" Value="1.0" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:closed">
|
||||
<Style Selector="^ /template/ Panel#PART_PaneRoot">
|
||||
<Setter Property="Transitions">
|
||||
<Transitions>
|
||||
<DoubleTransition
|
||||
Easing="{StaticResource SplitViewPaneAnimationEasing}"
|
||||
Property="Width"
|
||||
Duration="{StaticResource SplitViewPaneAnimationCloseDuration}" />
|
||||
</Transitions>
|
||||
</Setter>
|
||||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Rectangle#LightDismissLayer">
|
||||
<Setter Property="Transitions">
|
||||
<Transitions>
|
||||
<DoubleTransition
|
||||
Easing="{StaticResource SplitViewPaneAnimationEasing}"
|
||||
Property="Opacity"
|
||||
Duration="{StaticResource SplitViewPaneAnimationCloseDuration}" />
|
||||
</Transitions>
|
||||
</Setter>
|
||||
<Setter Property="Opacity" Value="0.0" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:lightdismiss /template/ Rectangle#LightDismissLayer">
|
||||
<Setter Property="Fill" Value="#99000000" />
|
||||
</Style>
|
||||
<Style Selector="^:overlay:open /template/ Rectangle#LightDismissLayer">
|
||||
<Setter Property="IsVisible" Value="True" />
|
||||
</Style>
|
||||
<Style Selector="^:compactoverlay:open /template/ Rectangle#LightDismissLayer">
|
||||
<Setter Property="IsVisible" Value="True" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
@@ -26,6 +26,7 @@
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/ScrollViewer.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/Slider.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/SplitButton.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/SplitView.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/TabControl.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/TabItem.axaml" />
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/TextBlock.axaml" />
|
||||
|
||||
12
src/Semi.Avalonia/Themes/Light/SplitView.axaml
Normal file
12
src/Semi.Avalonia/Themes/Light/SplitView.axaml
Normal file
@@ -0,0 +1,12 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="using:System">
|
||||
<!-- Add Resources Here -->
|
||||
<x:Double x:Key="SplitViewOpenPaneThemeLength">320</x:Double>
|
||||
<x:Double x:Key="SplitViewCompactPaneThemeLength">48</x:Double>
|
||||
<sys:TimeSpan x:Key="SplitViewPaneAnimationOpenDuration">00:00:00.2</sys:TimeSpan>
|
||||
<sys:TimeSpan x:Key="SplitViewPaneAnimationCloseDuration">00:00:00.1</sys:TimeSpan>
|
||||
<Easing x:Key="SplitViewPaneAnimationEasing">0.1,0.9,0.2,1.0</Easing>
|
||||
<SolidColorBrush x:Key="SplitViewSeparatorBackground" Opacity="0.08" Color="#1C1F23" />
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user