ToolStrip.xaml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <ToolBar Style="{DynamicResource ToolBarStyle1}" x:Class="CustomControls.ToolStrip"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:local="clr-namespace:CustomControls">
  5. <ToolBar.Resources>
  6. <LinearGradientBrush x:Key="ToolBarHorizontalBackground" EndPoint="0,1" StartPoint="0,0">
  7. <GradientStop Color="#FFFCFCFC" Offset="0.0"/>
  8. <GradientStop Color="#FFF2F2F2" Offset="1.0"/>
  9. </LinearGradientBrush>
  10. <LinearGradientBrush x:Key="ToolBarVerticalBackground" EndPoint="1,0" StartPoint="0,0">
  11. <GradientStop Color="#FFFCFCFC" Offset="0.0"/>
  12. <GradientStop Color="#FFF2F2F2" Offset="1.0"/>
  13. </LinearGradientBrush>
  14. <SolidColorBrush x:Key="ToolBarGripDark" Color="#FF6D6D6D"/>
  15. <SolidColorBrush x:Key="ToolBarGripLight" Color="#FFFFFFFF"/>
  16. <Style x:Key="ToolBarThumbStyle" TargetType="{x:Type Thumb}">
  17. <Setter Property="Template">
  18. <Setter.Value>
  19. <ControlTemplate TargetType="{x:Type Thumb}">
  20. <Border Background="Transparent" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
  21. <Rectangle>
  22. <Rectangle.Fill>
  23. <DrawingBrush TileMode="Tile" ViewboxUnits="Absolute" Viewbox="0,0,5,5" ViewportUnits="Absolute" Viewport="0,0,5,5">
  24. <DrawingBrush.Drawing>
  25. <DrawingGroup>
  26. <GeometryDrawing Brush="{DynamicResource ToolBarGripLight}" Geometry="M 1 1 L 1 3 L 3 3 L 3 1 z"/>
  27. <GeometryDrawing Brush="{DynamicResource ToolBarGripDark}" Geometry="M 0 0 L 0 2 L 2 2 L 2 0 z"/>
  28. </DrawingGroup>
  29. </DrawingBrush.Drawing>
  30. </DrawingBrush>
  31. </Rectangle.Fill>
  32. </Rectangle>
  33. </Border>
  34. <ControlTemplate.Triggers>
  35. <Trigger Property="IsMouseOver" Value="true">
  36. <Setter Property="Cursor" Value="SizeAll"/>
  37. </Trigger>
  38. </ControlTemplate.Triggers>
  39. </ControlTemplate>
  40. </Setter.Value>
  41. </Setter>
  42. </Style>
  43. <Style x:Key="ToolBarStyle1" TargetType="{x:Type local:ToolStrip}">
  44. <Setter Property="Background" Value="{DynamicResource ToolBarHorizontalBackground}"/>
  45. <Setter Property="Padding" Value="2"/>
  46. <Setter Property="Template">
  47. <Setter.Value>
  48. <ControlTemplate TargetType="{x:Type local:ToolStrip}">
  49. <Border x:Name="MainPanelBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" CornerRadius="3">
  50. <DockPanel x:Name="dockPanel" KeyboardNavigation.TabIndex="1" KeyboardNavigation.TabNavigation="Local" VerticalAlignment="Center">
  51. <Thumb x:Name="ToolBarThumb" Margin="-2,0,0,0" Padding="6,2,2,2" Style="{StaticResource ToolBarThumbStyle}" Width="12"/>
  52. <local:CustomToolBarPanel x:Name="PART_ToolBarPanel" IsItemsHost="true" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  53. </DockPanel>
  54. </Border>
  55. <ControlTemplate.Triggers>
  56. <Trigger Property="ToolBarTray.IsLocked" Value="true">
  57. <Setter Property="Visibility" TargetName="ToolBarThumb" Value="Collapsed"/>
  58. </Trigger>
  59. <Trigger Property="GripVisible" Value="False">
  60. <Setter Property="Visibility" TargetName="ToolBarThumb" Value="Collapsed"/>
  61. <Setter Property="CornerRadius" TargetName="MainPanelBorder" Value="0"/>
  62. </Trigger>
  63. <Trigger Property="Vertical" Value="true">
  64. <Setter Property="Orientation" TargetName="PART_ToolBarPanel" Value="Vertical"/>
  65. <Setter Property="VerticalAlignment" TargetName="dockPanel" Value="Top"/>
  66. <Setter Property="HorizontalAlignment" TargetName="dockPanel" Value="Center"/>
  67. <Setter Property="Height" TargetName="ToolBarThumb" Value="10"/>
  68. <Setter Property="Width" TargetName="ToolBarThumb" Value="Auto"/>
  69. <Setter Property="Margin" TargetName="ToolBarThumb" Value="-1,-3,0,0"/>
  70. <Setter Property="Padding" TargetName="ToolBarThumb" Value="5,6,6,1"/>
  71. <Setter Property="Margin" TargetName="PART_ToolBarPanel" Value="0,2,0,0"/>
  72. <Setter Property="DockPanel.Dock" TargetName="ToolBarThumb" Value="Top"/>
  73. <Setter Property="Background" Value="{DynamicResource ToolBarVerticalBackground}"/>
  74. </Trigger>
  75. <Trigger Property="IsEnabled" Value="false">
  76. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  77. </Trigger>
  78. </ControlTemplate.Triggers>
  79. </ControlTemplate>
  80. </Setter.Value>
  81. </Setter>
  82. </Style>
  83. </ToolBar.Resources>
  84. </ToolBar>