SukiSideMenuItem.axaml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <ResourceDictionary xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:content="clr-namespace:SukiUI.Content"
  4. xmlns:suki="clr-namespace:SukiUI.Controls">
  5. <Design.PreviewWith>
  6. <suki:SukiSideMenu>
  7. <suki:SukiSideMenuItem Header="Header">
  8. <suki:SukiSideMenuItem.Icon>
  9. <PathIcon Width="13"
  10. Height="13"
  11. Data="{x:Static content:Icons.Cross}" />
  12. </suki:SukiSideMenuItem.Icon>
  13. </suki:SukiSideMenuItem>
  14. <suki:SukiSideMenuItem Header="Header">
  15. <suki:SukiSideMenuItem.Icon>
  16. <PathIcon Width="13"
  17. Height="13"
  18. Data="{x:Static content:Icons.Cross}" />
  19. </suki:SukiSideMenuItem.Icon>
  20. <Grid />
  21. </suki:SukiSideMenuItem>
  22. </suki:SukiSideMenu>
  23. </Design.PreviewWith>
  24. <ControlTheme x:Key="SukiSideMenuItemStyle" TargetType="suki:SukiSideMenuItem">
  25. <Setter Property="Template">
  26. <ControlTemplate>
  27. <Panel>
  28. <Border Name="PART_Border"
  29. MinWidth="85"
  30. Margin="15,2"
  31. Padding="30,15,15,15"
  32. Background="{DynamicResource SukiPrimaryColor0}"
  33. CornerRadius="{DynamicResource MediumCornerRadius}">
  34. <Border.Transitions>
  35. <Transitions>
  36. <DoubleTransition Property="MaxHeight" Duration="0:0:1">
  37. <DoubleTransition.Easing>CubicEaseInOut</DoubleTransition.Easing>
  38. </DoubleTransition>
  39. <BrushTransition Property="Background" Duration="0:0:0.35" />
  40. <ThicknessTransition Property="Padding" Duration="0:0:0.35">
  41. <ThicknessTransition.Easing>CubicEaseInOut</ThicknessTransition.Easing>
  42. </ThicknessTransition>
  43. </Transitions>
  44. </Border.Transitions>
  45. <Panel>
  46. <DockPanel Name="PART_NormalDisplay" LastChildFill="True">
  47. <DockPanel.Resources />
  48. <ContentControl Name="PART_Icon"
  49. Width="24"
  50. Height="24"
  51. Content="{TemplateBinding Icon}"
  52. DockPanel.Dock="Left">
  53. <ContentControl.Transitions>
  54. <Transitions>
  55. <TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.2" />
  56. <DoubleTransition Property="Opacity" Duration="0:0:0.2" />
  57. </Transitions>
  58. </ContentControl.Transitions>
  59. </ContentControl>
  60. <Viewbox HorizontalAlignment="Left" StretchDirection="DownOnly">
  61. <TextBlock Name="PART_Header"
  62. Margin="15,0"
  63. VerticalAlignment="Center"
  64. FontSize="14"
  65. IsVisible="{Binding IsMenuExpanded, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type suki:SukiSideMenu}}}"
  66. Text="{TemplateBinding Header}" />
  67. </Viewbox>
  68. </DockPanel>
  69. <ContentPresenter Name="PART_AltDisplay"
  70. Content="{TemplateBinding Content}"
  71. ContentTemplate="{TemplateBinding ContentTemplate}" />
  72. </Panel>
  73. </Border>
  74. </Panel>
  75. </ControlTemplate>
  76. </Setter>
  77. <Style Selector="^.Compact /template/ Border#PART_Border">
  78. <Setter Property="Padding" Value="30,10,15,10" />
  79. <Setter Property="CornerRadius" Value="12" />
  80. </Style>
  81. <Style Selector="^:pointerover">
  82. <Style Selector="^ /template/ Border#PART_Border">
  83. <Setter Property="Background" Value="{DynamicResource SukiPrimaryColor5}" />
  84. <Setter Property="Cursor" Value="Hand" />
  85. </Style>
  86. </Style>
  87. <Style Selector="^[IsSelected=True]">
  88. <Style Selector="^ /template/ Border#PART_Border">
  89. <Setter Property="Background" Value="{DynamicResource SukiPrimaryColor10}" />
  90. </Style>
  91. <Style Selector="^ /template/ TextBlock#PART_Header">
  92. <Setter Property="FontWeight" Value="Bold" />
  93. <Setter Property="Foreground" Value="{DynamicResource SukiPrimaryColor}" />
  94. </Style>
  95. <Style Selector="^[IsContentMovable=True]">
  96. <Style Selector="^[IsTopMenuExpanded=True] /template/ Border#PART_Border">
  97. <Setter Property="Padding" Value="-10,15,15,15" />
  98. </Style>
  99. <Style Selector="^.Compact[IsTopMenuExpanded=True] /template/ Border#PART_Border">
  100. <Setter Property="Padding" Value="-10,10,15,10" />
  101. </Style>
  102. <Style Selector="^[IsTopMenuExpanded=True] /template/ ContentControl#PART_Icon">
  103. <Setter Property="Opacity" Value="0" />
  104. </Style>
  105. <Style Selector="^[IsTopMenuExpanded=False] /template/ ContentControl#PART_Icon">
  106. <Setter Property="Foreground" Value="{DynamicResource SukiPrimaryColor}" />
  107. <Setter Property="RenderTransform">
  108. <ScaleTransform ScaleX="1.12" ScaleY="1.12" />
  109. </Setter>
  110. </Style>
  111. </Style>
  112. <Style Selector="^[IsContentMovable=False]">
  113. <Style Selector="^ /template/ ContentControl#PART_Icon">
  114. <Setter Property="Foreground" Value="{DynamicResource SukiPrimaryColor}" />
  115. </Style>
  116. </Style>
  117. </Style>
  118. </ControlTheme>
  119. <ControlTheme x:Key="{x:Type suki:SukiSideMenuItem}"
  120. BasedOn="{StaticResource SukiSideMenuItemStyle}"
  121. TargetType="suki:SukiSideMenuItem" />
  122. </ResourceDictionary>