Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

200 wiersze
15 KiB

  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:bpa="clr-namespace:BPA.UIControl">
  4. <ResourceDictionary.MergedDictionaries>
  5. <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/Menu.xaml" />
  6. </ResourceDictionary.MergedDictionaries>
  7. <!-- 默认按钮 -->
  8. <Style x:Key="RubyerDropDownButton" TargetType="{x:Type bpa:DropDownButton}">
  9. <Setter Property="Background" Value="{DynamicResource Primary}" />
  10. <Setter Property="Foreground" Value="{DynamicResource WhiteForeground}" />
  11. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
  12. <Setter Property="BorderBrush" Value="{DynamicResource Border}" />
  13. <Setter Property="BorderThickness" Value="0" />
  14. <Setter Property="HorizontalContentAlignment" Value="Center" />
  15. <Setter Property="VerticalContentAlignment" Value="Center" />
  16. <Setter Property="Padding" Value="10 5" />
  17. <Setter Property="Cursor" Value="Hand" />
  18. <Setter Property="SnapsToDevicePixels" Value="True" />
  19. <Setter Property="MenuItemContainerStyle" Value="{StaticResource RubyerMenuItem}" />
  20. <Setter Property="IsShowSeparator" Value="True" />
  21. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource AllControlCornerRadius}" />
  22. <Setter Property="bpa:ControlHelper.MaskOpacity" Value="0.6" />
  23. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource MaskDark}" />
  24. <Setter Property="bpa:ButtonHelper.ShowShadow" Value="False" />
  25. <Setter Property="Template">
  26. <Setter.Value>
  27. <ControlTemplate TargetType="{x:Type bpa:DropDownButton}">
  28. <Border x:Name="border"
  29. Background="{TemplateBinding Background}"
  30. BorderBrush="{TemplateBinding BorderBrush}"
  31. BorderThickness="{TemplateBinding BorderThickness}"
  32. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  33. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
  34. <Grid>
  35. <Grid.ColumnDefinitions>
  36. <ColumnDefinition Width="*" />
  37. <ColumnDefinition Width="Auto" />
  38. </Grid.ColumnDefinitions>
  39. <Border x:Name="effectBorder"
  40. Grid.ColumnSpan="2"
  41. Background="{TemplateBinding Background}"
  42. BorderBrush="{TemplateBinding BorderBrush}"
  43. BorderThickness="{TemplateBinding BorderThickness}"
  44. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  45. Effect="{DynamicResource RightBottomEffect}"
  46. Visibility="Collapsed" />
  47. <bpa:ControlMask Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  48. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  49. IsActive="{TemplateBinding IsPressed}"
  50. MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
  51. <ContentPresenter x:Name="contentPresenter"
  52. Margin="{TemplateBinding Padding}"
  53. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  54. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  55. Focusable="False"
  56. RecognizesAccessKey="True"
  57. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  58. <Menu Style="{StaticResource RubyerMenu}"
  59. Grid.Column="1"
  60. bpa:ControlHelper.CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  61. bpa:ControlHelper.FocusedBrush="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  62. bpa:ControlHelper.MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  63. bpa:MenuHelper.IconWidth="{Binding ActualWidth, ElementName=icon, Converter={StaticResource AddConverter}, ConverterParameter=10}"
  64. BorderBrush="{TemplateBinding BorderBrush}"
  65. Foreground="{DynamicResource DefaultForeground}">
  66. <Separator Margin="0"
  67. BorderBrush="{TemplateBinding BorderBrush}"
  68. Visibility="{TemplateBinding IsShowSeparator, Converter={StaticResource BooleanToVisibleConverter}}" />
  69. <MenuItem x:Name="PART_DropDownMenuItem"
  70. Style="{StaticResource RubyerMenuItem}"
  71. Padding="5 0"
  72. IsSubmenuOpen="{TemplateBinding IsDropDownOpen}"
  73. ItemContainerStyle="{TemplateBinding MenuItemContainerStyle}"
  74. ItemTemplate="{TemplateBinding MenuItemTemplate}"
  75. ItemTemplateSelector="{TemplateBinding MenuItemTemplateSelector}"
  76. ItemsSource="{TemplateBinding MenuItemsSource}"
  77. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
  78. <MenuItem.Template>
  79. <ControlTemplate TargetType="{x:Type MenuItem}">
  80. <Border BorderBrush="{TemplateBinding BorderBrush}"
  81. BorderThickness="{TemplateBinding BorderThickness}"
  82. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}">
  83. <Grid>
  84. <bpa:ControlMask Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  85. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  86. IsActive="{TemplateBinding IsHighlighted}"
  87. MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
  88. <ContentPresenter Margin="{TemplateBinding Padding}"
  89. ContentSource="Header"
  90. RecognizesAccessKey="True"
  91. TextBlock.Foreground="{Binding Path=(bpa:HeaderHelper.Foreground), RelativeSource={RelativeSource AncestorType=MenuBase}}" />
  92. <Popup x:Name="Popup"
  93. AllowsTransparency="True"
  94. Focusable="False"
  95. HorizontalOffset="-5"
  96. IsOpen="{TemplateBinding IsSubmenuOpen}"
  97. Placement="Bottom"
  98. PlacementTarget="{Binding RelativeSource={RelativeSource AncestorType=bpa:DropDownButton}}"
  99. PopupAnimation="Fade">
  100. <Grid>
  101. <Border Margin="5"
  102. Padding="0 5"
  103. Background="{DynamicResource FloatBackground}"
  104. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  105. Effect="{DynamicResource AllDirectionEffect}" />
  106. <Border x:Name="SubmenuBorder"
  107. Margin="5"
  108. Padding="0 5"
  109. Background="{DynamicResource FloatBackground}"
  110. BorderBrush="{TemplateBinding BorderBrush}"
  111. BorderThickness="{TemplateBinding BorderThickness}"
  112. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  113. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
  114. <ScrollViewer Style="{StaticResource MenuScrollViewer}" CanContentScroll="True">
  115. <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
  116. </ScrollViewer>
  117. </Border>
  118. </Grid>
  119. </Popup>
  120. </Grid>
  121. </Border>
  122. <ControlTemplate.Triggers>
  123. <Trigger Property="IsSuspendingPopupAnimation" Value="True">
  124. <Setter TargetName="Popup" Property="PopupAnimation" Value="None" />
  125. </Trigger>
  126. <Trigger Property="IsEnabled" Value="False">
  127. <Setter Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  128. </Trigger>
  129. </ControlTemplate.Triggers>
  130. </ControlTemplate>
  131. </MenuItem.Template>
  132. <MenuItem.Header>
  133. <bpa:Icon x:Name="icon"
  134. Foreground="{TemplateBinding Foreground}"
  135. Type="ArrowDownSLine" />
  136. </MenuItem.Header>
  137. </MenuItem>
  138. </Menu>
  139. </Grid>
  140. </Border>
  141. <ControlTemplate.Triggers>
  142. <Trigger Property="IsPressed" Value="True">
  143. <Trigger.EnterActions>
  144. <BeginStoryboard>
  145. <Storyboard>
  146. <DoubleAnimation Storyboard.TargetName="effectBorder"
  147. Storyboard.TargetProperty="Effect.ShadowDepth"
  148. To="0"
  149. Duration="0:0:0.15">
  150. <DoubleAnimation.EasingFunction>
  151. <CubicEase EasingMode="EaseOut" />
  152. </DoubleAnimation.EasingFunction>
  153. </DoubleAnimation>
  154. </Storyboard>
  155. </BeginStoryboard>
  156. </Trigger.EnterActions>
  157. <Trigger.ExitActions>
  158. <BeginStoryboard>
  159. <Storyboard>
  160. <DoubleAnimation Storyboard.TargetName="effectBorder"
  161. Storyboard.TargetProperty="Effect.ShadowDepth"
  162. Duration="0:0:0.25">
  163. <DoubleAnimation.EasingFunction>
  164. <CubicEase EasingMode="EaseIn" />
  165. </DoubleAnimation.EasingFunction>
  166. </DoubleAnimation>
  167. </Storyboard>
  168. </BeginStoryboard>
  169. </Trigger.ExitActions>
  170. </Trigger>
  171. <Trigger Property="IsEnabled" Value="False">
  172. <Setter TargetName="border" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  173. </Trigger>
  174. <Trigger Property="bpa:ButtonHelper.ShowShadow" Value="True">
  175. <Setter TargetName="effectBorder" Property="Visibility" Value="Visible" />
  176. </Trigger>
  177. <MultiDataTrigger>
  178. <MultiDataTrigger.Conditions>
  179. <Condition Binding="{Binding DependencyObjectType.SystemType, RelativeSource={RelativeSource Self}}" Value="{x:Type Button}" />
  180. <Condition Binding="{Binding IsDefault, RelativeSource={RelativeSource Self}}" Value="True" />
  181. </MultiDataTrigger.Conditions>
  182. <Setter TargetName="effectBorder" Property="Visibility" Value="Visible" />
  183. <Setter TargetName="effectBorder" Property="Effect" Value="{DynamicResource AllDirectionEffect3}" />
  184. </MultiDataTrigger>
  185. </ControlTemplate.Triggers>
  186. </ControlTemplate>
  187. </Setter.Value>
  188. </Setter>
  189. </Style>
  190. </ResourceDictionary>