SideMenuBaseStyle.xaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:hc="clr-namespace:HandyControl.Controls">
  4. <Style x:Key="SideMenuItemBaseStyle" BasedOn="{StaticResource BaseStyle}" TargetType="hc:SideMenuItem">
  5. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualRadius0Margin0}"/>
  6. <Setter Property="Role" Value="Item"/>
  7. <Setter Property="VerticalContentAlignment" Value="Center"/>
  8. <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
  9. <Setter Property="MinHeight" Value="40"/>
  10. <Setter Property="Template">
  11. <Setter.Value>
  12. <ControlTemplate TargetType="hc:SideMenuItem">
  13. <Border Name="BorderRoot" Background="{TemplateBinding Background}">
  14. <hc:SimplePanel>
  15. <Rectangle Width="4" Fill="{TemplateBinding BorderBrush}" HorizontalAlignment="Left"/>
  16. <ContentControl Margin="4,0,0,0">
  17. <DockPanel Margin="{TemplateBinding Padding}">
  18. <ContentControl Width="40" Name="PresenterIcon">
  19. <ContentPresenter ContentSource="Icon" HorizontalAlignment="Center" VerticalAlignment="Center"/>
  20. </ContentControl>
  21. <ContentPresenter Name="PresenterHeader" ContentSource="Header" Margin="6,0,0,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
  22. </DockPanel>
  23. </ContentControl>
  24. </hc:SimplePanel>
  25. </Border>
  26. <ControlTemplate.Triggers>
  27. <Trigger Property="Icon" Value="{x:Null}">
  28. <Setter TargetName="PresenterIcon" Property="Visibility" Value="Collapsed"/>
  29. </Trigger>
  30. <DataTrigger Binding="{Binding IsSelected,RelativeSource={RelativeSource AncestorType=hc:SideMenuItem}}" Value="True">
  31. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  32. </DataTrigger>
  33. <Trigger Property="IsSelected" Value="True">
  34. <Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
  35. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  36. <Setter Property="TextElement.FontWeight" Value="Bold" TargetName="PresenterHeader"/>
  37. </Trigger>
  38. <Trigger Property="IsMouseOver" Value="true">
  39. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  40. </Trigger>
  41. </ControlTemplate.Triggers>
  42. </ControlTemplate>
  43. </Setter.Value>
  44. </Setter>
  45. </Style>
  46. <Style x:Key="SideMenuItemAccordionBaseStyle" BasedOn="{StaticResource SideMenuItemBaseStyle}" TargetType="hc:SideMenuItem">
  47. <Setter Property="Template">
  48. <Setter.Value>
  49. <ControlTemplate TargetType="hc:SideMenuItem">
  50. <Border Name="BorderRoot" Background="{TemplateBinding Background}">
  51. <hc:SimplePanel>
  52. <Rectangle Width="4" Fill="{TemplateBinding BorderBrush}" HorizontalAlignment="Left"/>
  53. <ContentControl Margin="4,0,0,0">
  54. <DockPanel Margin="{TemplateBinding Padding}">
  55. <ContentControl Width="40" Name="PresenterIcon">
  56. <ContentPresenter ContentSource="Icon" HorizontalAlignment="Center" VerticalAlignment="Center"/>
  57. </ContentControl>
  58. <ContentPresenter Name="PresenterHeader" ContentSource="Header" Margin="6,0,0,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
  59. </DockPanel>
  60. </ContentControl>
  61. </hc:SimplePanel>
  62. </Border>
  63. <ControlTemplate.Triggers>
  64. <Trigger Property="Icon" Value="{x:Null}">
  65. <Setter TargetName="PresenterIcon" Property="Visibility" Value="Collapsed"/>
  66. </Trigger>
  67. <DataTrigger Binding="{Binding IsSelected,RelativeSource={RelativeSource AncestorType=hc:SideMenuItem}}" Value="True">
  68. <Setter Property="BorderBrush" Value="Transparent"/>
  69. </DataTrigger>
  70. <Trigger Property="IsSelected" Value="True">
  71. <Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
  72. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  73. <Setter Property="TextElement.FontWeight" Value="Bold" TargetName="PresenterHeader"/>
  74. </Trigger>
  75. <Trigger Property="IsMouseOver" Value="true">
  76. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  77. </Trigger>
  78. </ControlTemplate.Triggers>
  79. </ControlTemplate>
  80. </Setter.Value>
  81. </Setter>
  82. </Style>
  83. <Style x:Key="SideMenuItemHeaderBaseStyle" BasedOn="{StaticResource BaseStyle}" TargetType="hc:SideMenuItem">
  84. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualRadius0Margin0}"/>
  85. <Setter Property="VerticalContentAlignment" Value="Center"/>
  86. <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
  87. <Setter Property="ItemContainerStyle" Value="{StaticResource SideMenuItemBaseStyle}"/>
  88. <Setter Property="Template">
  89. <Setter.Value>
  90. <ControlTemplate TargetType="hc:SideMenuItem">
  91. <Border Name="BorderRoot" Background="{TemplateBinding Background}">
  92. <Grid>
  93. <Grid.RowDefinitions>
  94. <RowDefinition MinHeight="48"/>
  95. <RowDefinition/>
  96. </Grid.RowDefinitions>
  97. <Border Name="BorderBack" Background="{TemplateBinding Background}"/>
  98. <ContentControl Grid.Row="0" Margin="4,0,0,0">
  99. <DockPanel Margin="{TemplateBinding Padding}" Name="PanelHeader" Background="Transparent">
  100. <ContentControl Width="40" Name="PresenterIcon">
  101. <ContentPresenter ContentSource="Icon" HorizontalAlignment="Center" VerticalAlignment="Center"/>
  102. </ContentControl>
  103. <ContentPresenter Name="PresenterHeader" ContentSource="Header" Margin="6,0,0,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
  104. </DockPanel>
  105. </ContentControl>
  106. <StackPanel Grid.Row="1" x:Name="PART_Panel" Visibility="Collapsed" Height="{Binding PanelAreaLength,RelativeSource={RelativeSource AncestorType=hc:SideMenu}}"/>
  107. </Grid>
  108. </Border>
  109. <ControlTemplate.Triggers>
  110. <Trigger Property="Icon" Value="{x:Null}">
  111. <Setter TargetName="PresenterIcon" Property="Visibility" Value="Collapsed"/>
  112. </Trigger>
  113. <Trigger Property="IsSelected" Value="True">
  114. <Setter TargetName="BorderBack" Property="BorderThickness" Value="4,0,0,0"/>
  115. <Setter TargetName="BorderBack" Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  116. <Setter Property="TextElement.FontWeight" Value="Bold" TargetName="PresenterHeader"/>
  117. </Trigger>
  118. <Trigger SourceName="PanelHeader" Property="IsMouseOver" Value="true">
  119. <Setter TargetName="BorderBack" Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  120. </Trigger>
  121. </ControlTemplate.Triggers>
  122. </ControlTemplate>
  123. </Setter.Value>
  124. </Setter>
  125. </Style>
  126. <Style x:Key="SideMenuItemHeaderAccordionBaseStyle" BasedOn="{StaticResource SideMenuItemHeaderBaseStyle}" TargetType="hc:SideMenuItem">
  127. <Setter Property="ItemContainerStyle" Value="{StaticResource SideMenuItemAccordionBaseStyle}"/>
  128. <Setter Property="Template">
  129. <Setter.Value>
  130. <ControlTemplate TargetType="hc:SideMenuItem">
  131. <Border Name="BorderRoot" Background="{TemplateBinding Background}">
  132. <Grid>
  133. <Grid.RowDefinitions>
  134. <RowDefinition MinHeight="48"/>
  135. <RowDefinition/>
  136. </Grid.RowDefinitions>
  137. <Border Name="BorderBack" Background="{TemplateBinding Background}"/>
  138. <ContentControl Grid.Row="0" Margin="4,0,0,0">
  139. <DockPanel Margin="{TemplateBinding Padding}" Name="PanelHeader" Background="Transparent">
  140. <ContentControl Width="40" Name="PresenterIcon">
  141. <ContentPresenter ContentSource="Icon" HorizontalAlignment="Center" VerticalAlignment="Center"/>
  142. </ContentControl>
  143. <ContentPresenter Name="PresenterHeader" ContentSource="Header" Margin="6,0,0,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
  144. </DockPanel>
  145. </ContentControl>
  146. <ScrollViewer Visibility="{Binding Visibility,ElementName=PART_Panel}" Grid.Row="1" Height="{Binding PanelAreaLength,RelativeSource={RelativeSource AncestorType=hc:SideMenu}}">
  147. <StackPanel x:Name="PART_Panel" Visibility="Collapsed"/>
  148. </ScrollViewer>
  149. </Grid>
  150. </Border>
  151. <ControlTemplate.Triggers>
  152. <Trigger Property="Icon" Value="{x:Null}">
  153. <Setter TargetName="PresenterIcon" Property="Visibility" Value="Collapsed"/>
  154. </Trigger>
  155. <Trigger Property="IsSelected" Value="True">
  156. <Setter TargetName="BorderBack" Property="BorderThickness" Value="4,0,0,0"/>
  157. <Setter TargetName="BorderBack" Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  158. <Setter Property="TextElement.FontWeight" Value="Bold" TargetName="PresenterHeader"/>
  159. </Trigger>
  160. <Trigger SourceName="PanelHeader" Property="IsMouseOver" Value="true">
  161. <Setter TargetName="BorderBack" Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  162. </Trigger>
  163. </ControlTemplate.Triggers>
  164. </ControlTemplate>
  165. </Setter.Value>
  166. </Setter>
  167. </Style>
  168. <Style x:Key="SideMenuBaseStyle" TargetType="hc:SideMenu">
  169. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  170. <Setter Property="Focusable" Value="False"/>
  171. <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
  172. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  173. <Setter Property="ItemContainerStyle" Value="{StaticResource SideMenuItemHeaderBaseStyle}"/>
  174. <Setter Property="Template">
  175. <Setter.Value>
  176. <ControlTemplate TargetType="hc:SideMenu">
  177. <Border Name="BorderRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
  178. <ScrollViewer>
  179. <StackPanel x:Name="PART_Panel"/>
  180. </ScrollViewer>
  181. </Border>
  182. </ControlTemplate>
  183. </Setter.Value>
  184. </Setter>
  185. </Style>
  186. </ResourceDictionary>