-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SplitView control #4174
Add SplitView control #4174
Changes from 1 commit
8fb6e52
0784239
e385dbc
61294fc
59352fa
3a17e23
dd0ae88
8b5eead
e12201b
8cd328b
d522def
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
<Styles xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
|
||
<Styles.Resources> | ||
<x:Double x:Key="SplitViewOpenPaneThemeLength">320</x:Double> | ||
<x:Double x:Key="SplitViewCompactPaneThemeLength">48</x:Double> | ||
|
||
<!-- Not used here (directly) since they're strings, but preserving for reference | ||
<x:String x:Key="SplitViewPaneAnimationOpenDuration">00:00:00.2</x:String> | ||
<x:String x:Key="SplitViewPaneAnimationOpenPreDuration">00:00:00.19999</x:String> | ||
<x:String x:Key="SplitViewPaneAnimationCloseDuration">00:00:00.1</x:String>--> | ||
</Styles.Resources> | ||
|
||
<Style Selector="SplitView"> | ||
<Setter Property="OpenPaneLength" Value="{DynamicResource SplitViewOpenPaneThemeLength}" /> | ||
<Setter Property="CompactPaneLength" Value="{DynamicResource SplitViewCompactPaneThemeLength}" /> | ||
<Setter Property="PaneBackground" Value="{DynamicResource SystemControlPageBackgroundChromeLowBrush}" /> | ||
</Style> | ||
|
||
<!-- Left --> | ||
<Style Selector="SplitView:left"> | ||
<Setter Property="Template"> | ||
<ControlTemplate> | ||
<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" Background="{TemplateBinding PaneBackground}" | ||
ClipToBounds="True" | ||
HorizontalAlignment="Left" | ||
ZIndex="100"> | ||
<Border Child="{TemplateBinding Pane}"/> | ||
<Rectangle Name="HCPaneBorder" Fill="{DynamicResource SystemControlForegroundTransparentBrush}" Width="1" HorizontalAlignment="Right" /> | ||
</Panel> | ||
|
||
<Panel Name="ContentRoot"> | ||
<Border Child="{TemplateBinding Content}" /> | ||
<Rectangle Name="LightDismissLayer"/> | ||
</Panel> | ||
|
||
</Grid> | ||
</ControlTemplate> | ||
</Setter> | ||
</Style> | ||
|
||
<!-- Overlay --> | ||
<Style Selector="SplitView:overlay:left /template/ Panel#PART_PaneRoot"> | ||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" /> | ||
<!-- ColumnSpan should be 2 --> | ||
<Setter Property="Grid.ColumnSpan" Value="1"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ColumnSpan should technically be 2 here (and also in :compactoverlay below). When I copied the code into Avalonia from my test project this broke and opening the pane would also move the content slightly, but only when the pane is on the left. Not sure why this is being handled differently... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well.. could you try explicitly setting grid.column too? just in case there's some bug in there... |
||
<Setter Property="Grid.Column" Value="0"/> | ||
</Style> | ||
<Style Selector="SplitView:overlay:left /template/ Panel#ContentRoot"> | ||
<Setter Property="Grid.Column" Value="1"/> | ||
<Setter Property="Grid.ColumnSpan" Value="2"/> | ||
</Style> | ||
|
||
<!-- CompactInline --> | ||
<Style Selector="SplitView:compactinline:left /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="SplitView:compactinline:left /template/ Panel#ContentRoot"> | ||
<Setter Property="Grid.Column" Value="1"/> | ||
<Setter Property="Grid.ColumnSpan" Value="1"/> | ||
</Style> | ||
|
||
<!-- CompactOverlay --> | ||
<Style Selector="SplitView:compactoverlay:left /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="SplitView:compactoverlay:left /template/ Panel#ContentRoot"> | ||
<Setter Property="Grid.Column" Value="1"/> | ||
<Setter Property="Grid.ColumnSpan" Value="1"/> | ||
</Style> | ||
|
||
<!-- Inline --> | ||
<Style Selector="SplitView:inline:left /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="SplitView:inline:left /template/ Panel#ContentRoot"> | ||
<Setter Property="Grid.Column" Value="1"/> | ||
<Setter Property="Grid.ColumnSpan" Value="1"/> | ||
</Style> | ||
|
||
<!-- Right --> | ||
<Style Selector="SplitView: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" Background="{TemplateBinding PaneBackground}" | ||
ClipToBounds="True" | ||
HorizontalAlignment="Right" | ||
ZIndex="100"> | ||
<Border Child="{TemplateBinding Pane}"/> | ||
<Rectangle Name="HCPaneBorder" | ||
Fill="{DynamicResource SystemControlForegroundTransparentBrush}" | ||
Width="1" HorizontalAlignment="Left" /> | ||
</Panel> | ||
|
||
<Panel Name="ContentRoot"> | ||
<Border Child="{TemplateBinding Content}" /> | ||
<Rectangle Name="LightDismissLayer"/> | ||
</Panel> | ||
|
||
</Grid> | ||
</ControlTemplate> | ||
</Setter> | ||
</Style> | ||
|
||
<!-- Overlay --> | ||
<Style Selector="SplitView:overlay:right /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="SplitView:overlay:right /template/ Panel#ContentRoot"> | ||
<Setter Property="Grid.Column" Value="0"/> | ||
<Setter Property="Grid.ColumnSpan" Value="2"/> | ||
</Style> | ||
|
||
<!-- CompactInline --> | ||
<Style Selector="SplitView:compactinline:right /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="SplitView:compactinline:right /template/ Panel#ContentRoot"> | ||
<Setter Property="Grid.Column" Value="0"/> | ||
<Setter Property="Grid.ColumnSpan" Value="1"/> | ||
</Style> | ||
|
||
<!-- CompactOverlay --> | ||
<Style Selector="SplitView:compactoverlay:right /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="SplitView:compactoverlay:right /template/ Panel#ContentRoot"> | ||
<Setter Property="Grid.Column" Value="0"/> | ||
<Setter Property="Grid.ColumnSpan" Value="1"/> | ||
</Style> | ||
|
||
<!-- Inline --> | ||
<Style Selector="SplitView:inline:right /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="SplitView:inline:right /template/ Panel#ContentRoot"> | ||
<Setter Property="Grid.Column" Value="0"/> | ||
<Setter Property="Grid.ColumnSpan" Value="1"/> | ||
</Style> | ||
|
||
<!-- Open/Close Pane animation | ||
Uses KeySpline in WinUI, QuinticEaseOut easing seemed to match best | ||
amwx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
--> | ||
<Style Selector="SplitView:open /template/ Panel#PART_PaneRoot"> | ||
<Setter Property="Transitions"> | ||
<Transitions> | ||
<DoubleTransition Property="Width" Duration="00:00:00.2" Easing="QuinticEaseOut" /> | ||
</Transitions> | ||
</Setter> | ||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=OpenPaneLength}" /> | ||
</Style> | ||
<Style Selector="SplitView:open /template/ Rectangle#LightDismissLayer"> | ||
<Setter Property="Transitions"> | ||
<Transitions> | ||
<DoubleTransition Property="Opacity" Duration="00:00:00.2" Easing="QuinticEaseOut" /> | ||
</Transitions> | ||
</Setter> | ||
<Setter Property="Opacity" Value="1.0"/> | ||
</Style> | ||
|
||
<Style Selector="SplitView:closed /template/ Panel#PART_PaneRoot"> | ||
<Setter Property="Transitions"> | ||
<Transitions> | ||
<DoubleTransition Property="Width" Duration="00:00:00.1" Easing="QuinticEaseOut" /> | ||
</Transitions> | ||
</Setter> | ||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" /> | ||
</Style> | ||
<Style Selector="SplitView:closed /template/ Rectangle#LightDismissLayer"> | ||
<Setter Property="Transitions"> | ||
<Transitions> | ||
<DoubleTransition Property="Opacity" Duration="00:00:00.2" Easing="QuinticEaseOut" /> | ||
</Transitions> | ||
</Setter> | ||
<Setter Property="Opacity" Value="0.0"/> | ||
</Style> | ||
|
||
<Style Selector="SplitView /template/ Rectangle#LightDismissLayer"> | ||
<Setter Property="IsVisible" Value="False"/> | ||
<Setter Property="Fill" Value="Transparent" /> | ||
</Style> | ||
<Style Selector="SplitView:lightdismiss /template/ Rectangle#LightDismissLayer"> | ||
<Setter Property="Fill" Value="{DynamicResource SplitViewLightDismissOverlayBackground}" /> | ||
</Style> | ||
|
||
<Style Selector="SplitView:overlay:open /template/ Rectangle#LightDismissLayer"> | ||
<Setter Property="IsVisible" Value="True"/> | ||
</Style> | ||
<Style Selector="SplitView:compactoverlay:open /template/ Rectangle#LightDismissLayer"> | ||
<Setter Property="IsVisible" Value="True"/> | ||
</Style> | ||
|
||
</Styles> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is throwing a binding error (you can see it on load or when you change the
PanePlacement
).[Binding] Error in binding to 'Avalonia.Controls.ColumnDefinition'.'Width': 'Null value in expression ''.' (ColumnDefinition #41130254)
Like my comment below, this only started happening when I moved the code from my test project into avalonia. I know and have checked
TemplateSettings.PaneColumnGridLength
is not null so I'm not sure why this is happening.