SplitView.axaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <ResourceDictionary xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:sys="using:System">
  4. <Design.PreviewWith>
  5. <Border Width="400" Height="400">
  6. <SplitView DisplayMode="Inline" IsPaneOpen="True">
  7. <SplitView.Pane>
  8. <Border Background="Green" />
  9. </SplitView.Pane>
  10. <SplitView.Content>
  11. <Border Background="Blue" />
  12. </SplitView.Content>
  13. </SplitView>
  14. </Border>
  15. </Design.PreviewWith>
  16. <x:Double x:Key="SplitViewOpenPaneThemeLength">320</x:Double>
  17. <x:Double x:Key="SplitViewCompactPaneThemeLength">48</x:Double>
  18. <SolidColorBrush x:Key="SplitViewLightDismissOverlayBackground"
  19. Opacity="0.6"
  20. Color="{DynamicResource ThemeControlLowColor}" />
  21. <sys:TimeSpan x:Key="SplitViewPaneAnimationOpenDuration">00:00:0.4</sys:TimeSpan>
  22. <sys:TimeSpan x:Key="SplitViewPaneAnimationCloseDuration">00:00:0.4</sys:TimeSpan>
  23. <!-- Not used here (directly), but preserving for reference
  24. <x:String x:Key="SplitViewPaneAnimationOpenPreDuration">00:00:00.19999</x:String>-->
  25. <ControlTheme x:Key="{x:Type SplitView}" TargetType="SplitView">
  26. <Setter Property="OpenPaneLength" Value="{DynamicResource SplitViewOpenPaneThemeLength}" />
  27. <Setter Property="CompactPaneLength" Value="{DynamicResource SplitViewCompactPaneThemeLength}" />
  28. <Setter Property="PaneBackground" Value="{DynamicResource ThemeControlHighlightLowBrush}" />
  29. <!-- Left -->
  30. <Style Selector="^:left">
  31. <Setter Property="Template">
  32. <ControlTemplate TargetType="SplitView">
  33. <Grid Name="Container" Background="{TemplateBinding Background}">
  34. <Grid.ColumnDefinitions>
  35. <ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.PaneColumnGridLength}" />
  36. <ColumnDefinition Width="*" />
  37. </Grid.ColumnDefinitions>
  38. <Panel Name="PART_PaneRoot"
  39. HorizontalAlignment="Left"
  40. Background="Transparent"
  41. ClipToBounds="True"
  42. ZIndex="100">
  43. <ContentPresenter x:Name="PART_PanePresenter"
  44. Content="{TemplateBinding Pane}"
  45. ContentTemplate="{TemplateBinding PaneTemplate}" />
  46. <Rectangle Name="HCPaneBorder"
  47. Width="1"
  48. HorizontalAlignment="Right"
  49. Fill="Transparent" />
  50. </Panel>
  51. <Panel Name="ContentRoot">
  52. <ContentPresenter x:Name="PART_ContentPresenter"
  53. Content="{TemplateBinding Content}"
  54. ContentTemplate="{TemplateBinding ContentTemplate}" />
  55. <Rectangle Name="LightDismissLayer" />
  56. </Panel>
  57. </Grid>
  58. </ControlTemplate>
  59. </Setter>
  60. </Style>
  61. <!-- Overlay -->
  62. <Style Selector="^:overlay:left /template/ Panel#PART_PaneRoot">
  63. <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
  64. <!-- ColumnSpan should be 2 -->
  65. <Setter Property="Grid.ColumnSpan" Value="1" />
  66. <Setter Property="Grid.Column" Value="0" />
  67. </Style>
  68. <Style Selector="^:overlay:left /template/ Panel#ContentRoot">
  69. <Setter Property="Grid.Column" Value="1" />
  70. <Setter Property="Grid.ColumnSpan" Value="2" />
  71. </Style>
  72. <!-- CompactInline -->
  73. <Style Selector="^:compactinline:left /template/ Panel#PART_PaneRoot">
  74. <Setter Property="Grid.ColumnSpan" Value="1" />
  75. <Setter Property="Grid.Column" Value="0" />
  76. <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
  77. </Style>
  78. <Style Selector="^:compactinline:left /template/ Panel#ContentRoot">
  79. <Setter Property="Grid.Column" Value="1" />
  80. <Setter Property="Grid.ColumnSpan" Value="1" />
  81. </Style>
  82. <!-- CompactOverlay -->
  83. <Style Selector="^:compactoverlay:left /template/ Panel#PART_PaneRoot">
  84. <!-- ColumnSpan should be 2 -->
  85. <Setter Property="Grid.ColumnSpan" Value="1" />
  86. <Setter Property="Grid.Column" Value="0" />
  87. <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
  88. </Style>
  89. <Style Selector="^:compactoverlay:left /template/ Panel#ContentRoot">
  90. <Setter Property="Grid.Column" Value="1" />
  91. <Setter Property="Grid.ColumnSpan" Value="1" />
  92. </Style>
  93. <!-- Inline -->
  94. <Style Selector="^:inline:left /template/ Panel#PART_PaneRoot">
  95. <Setter Property="Grid.ColumnSpan" Value="1" />
  96. <Setter Property="Grid.Column" Value="0" />
  97. <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
  98. </Style>
  99. <Style Selector="^:inline:left /template/ Panel#ContentRoot">
  100. <Setter Property="Grid.Column" Value="1" />
  101. <Setter Property="Grid.ColumnSpan" Value="1" />
  102. </Style>
  103. <!-- Right -->
  104. <Style Selector="^:right">
  105. <Setter Property="Template">
  106. <ControlTemplate TargetType="SplitView">
  107. <Grid Name="Container" Background="{TemplateBinding Background}">
  108. <Grid.ColumnDefinitions>
  109. <ColumnDefinition Width="*" />
  110. <ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.PaneColumnGridLength}" />
  111. </Grid.ColumnDefinitions>
  112. <Panel Name="PART_PaneRoot"
  113. HorizontalAlignment="Right"
  114. Background="{TemplateBinding PaneBackground}"
  115. ClipToBounds="True"
  116. ZIndex="100">
  117. <ContentPresenter x:Name="PART_PanePresenter"
  118. Content="{TemplateBinding Pane}"
  119. ContentTemplate="{TemplateBinding PaneTemplate}" />
  120. <Rectangle Name="HCPaneBorder"
  121. Width="1"
  122. HorizontalAlignment="Left"
  123. Fill="Transparent" />
  124. </Panel>
  125. <Panel Name="ContentRoot">
  126. <ContentPresenter x:Name="PART_ContentPresenter"
  127. Content="{TemplateBinding Content}"
  128. ContentTemplate="{TemplateBinding ContentTemplate}" />
  129. <Rectangle Name="LightDismissLayer" />
  130. </Panel>
  131. </Grid>
  132. </ControlTemplate>
  133. </Setter>
  134. </Style>
  135. <!-- Overlay -->
  136. <Style Selector="^:overlay:right /template/ Panel#PART_PaneRoot">
  137. <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
  138. <Setter Property="Grid.ColumnSpan" Value="2" />
  139. <Setter Property="Grid.Column" Value="1" />
  140. </Style>
  141. <Style Selector="^:overlay:right /template/ Panel#ContentRoot">
  142. <Setter Property="Grid.Column" Value="0" />
  143. <Setter Property="Grid.ColumnSpan" Value="2" />
  144. </Style>
  145. <!-- CompactInline -->
  146. <Style Selector="^:compactinline:right /template/ Panel#PART_PaneRoot">
  147. <Setter Property="Grid.ColumnSpan" Value="1" />
  148. <Setter Property="Grid.Column" Value="1" />
  149. <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
  150. </Style>
  151. <Style Selector="^:compactinline:right /template/ Panel#ContentRoot">
  152. <Setter Property="Grid.Column" Value="0" />
  153. <Setter Property="Grid.ColumnSpan" Value="1" />
  154. </Style>
  155. <!-- CompactOverlay -->
  156. <Style Selector="^:compactoverlay:right /template/ Panel#PART_PaneRoot">
  157. <Setter Property="Grid.ColumnSpan" Value="2" />
  158. <Setter Property="Grid.Column" Value="1" />
  159. <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
  160. </Style>
  161. <Style Selector="^:compactoverlay:right /template/ Panel#ContentRoot">
  162. <Setter Property="Grid.Column" Value="0" />
  163. <Setter Property="Grid.ColumnSpan" Value="1" />
  164. </Style>
  165. <!-- Inline -->
  166. <Style Selector="^:inline:right /template/ Panel#PART_PaneRoot">
  167. <Setter Property="Grid.ColumnSpan" Value="1" />
  168. <Setter Property="Grid.Column" Value="1" />
  169. <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
  170. </Style>
  171. <Style Selector="^:inline:right /template/ Panel#ContentRoot">
  172. <Setter Property="Grid.Column" Value="0" />
  173. <Setter Property="Grid.ColumnSpan" Value="1" />
  174. </Style>
  175. <!-- Open/Close Pane animation -->
  176. <Style Selector="^:open /template/ Panel#PART_PaneRoot">
  177. <Setter Property="Transitions">
  178. <Transitions>
  179. <DoubleTransition Easing="SineEaseOut"
  180. Property="Width"
  181. Duration="{StaticResource SplitViewPaneAnimationOpenDuration}" />
  182. </Transitions>
  183. </Setter>
  184. <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=OpenPaneLength}" />
  185. </Style>
  186. <Style Selector="^:open /template/ Rectangle#LightDismissLayer">
  187. <Setter Property="Transitions">
  188. <Transitions>
  189. <DoubleTransition Easing="SineEaseOut"
  190. Property="Opacity"
  191. Duration="{StaticResource SplitViewPaneAnimationOpenDuration}" />
  192. </Transitions>
  193. </Setter>
  194. <Setter Property="Opacity" Value="1.0" />
  195. </Style>
  196. <Style Selector="^:closed /template/ Panel#PART_PaneRoot">
  197. <Setter Property="Transitions">
  198. <Transitions>
  199. <DoubleTransition Easing="SineEaseOut"
  200. Property="Width"
  201. Duration="{StaticResource SplitViewPaneAnimationCloseDuration}" />
  202. </Transitions>
  203. </Setter>
  204. <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" />
  205. </Style>
  206. <Style Selector="^:closed /template/ Rectangle#LightDismissLayer">
  207. <Setter Property="Transitions">
  208. <Transitions>
  209. <DoubleTransition Easing="SineEaseOut"
  210. Property="Opacity"
  211. Duration="{StaticResource SplitViewPaneAnimationCloseDuration}" />
  212. </Transitions>
  213. </Setter>
  214. <Setter Property="Opacity" Value="0.0" />
  215. </Style>
  216. <Style Selector="^ /template/ Rectangle#LightDismissLayer">
  217. <Setter Property="IsVisible" Value="False" />
  218. <Setter Property="Fill" Value="Transparent" />
  219. </Style>
  220. <Style Selector="^:lightdismiss /template/ Rectangle#LightDismissLayer">
  221. <Setter Property="Fill" Value="{DynamicResource SplitViewLightDismissOverlayBackground}" />
  222. </Style>
  223. <Style Selector="^:overlay:open /template/ Rectangle#LightDismissLayer">
  224. <Setter Property="IsVisible" Value="True" />
  225. </Style>
  226. <Style Selector="^:compactoverlay:open /template/ Rectangle#LightDismissLayer">
  227. <Setter Property="IsVisible" Value="True" />
  228. </Style>
  229. </ControlTheme>
  230. </ResourceDictionary>