Generic.xaml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:UI="clr-namespace:CustomUI">
  5. <Style TargetType="{x:Type UI:SegmentItem}">
  6. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  7. <Setter Property="BorderThickness" Value="1,0,0,0" />
  8. <Setter Property="Padding" Value="15,5" />
  9. <Setter Property="BorderBrush" Value="{Binding BorderBrush, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UI:SegmentControl}}}" />
  10. <Setter Property="Template">
  11. <Setter.Value>
  12. <ControlTemplate TargetType="{x:Type UI:SegmentItem}">
  13. <Border
  14. x:Name="PART_ItemBorder"
  15. Padding="{TemplateBinding Padding}"
  16. Background="Transparent"
  17. BorderBrush="{TemplateBinding BorderBrush}"
  18. BorderThickness="{TemplateBinding BorderThickness}"
  19. CornerRadius="{TemplateBinding CornerRadius}"
  20. SnapsToDevicePixels="True"
  21. UseLayoutRounding="True">
  22. <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
  23. </Border>
  24. <ControlTemplate.Triggers>
  25. <Trigger Property="IsSelected" Value="True">
  26. <Setter Property="Foreground" Value="White" />
  27. <Setter TargetName="PART_ItemBorder" Property="Background" Value="{Binding BorderBrush, RelativeSource={RelativeSource TemplatedParent}}" />
  28. </Trigger>
  29. <Trigger Property="IsFirstItem" Value="True">
  30. <Setter TargetName="PART_ItemBorder" Property="BorderThickness" Value="0" />
  31. </Trigger>
  32. <Trigger Property="IsLastItem" Value="True" />
  33. <Trigger Property="IsMiddleItem" Value="True" />
  34. </ControlTemplate.Triggers>
  35. </ControlTemplate>
  36. </Setter.Value>
  37. </Setter>
  38. </Style>
  39. <SolidColorBrush x:Key="ListBox.Static.Background" Color="#FFFFFFFF" />
  40. <SolidColorBrush x:Key="ListBox.Static.Border" Color="#0079FF" />
  41. <SolidColorBrush x:Key="ListBox.Disabled.Background" Color="#FFFFFFFF" />
  42. <SolidColorBrush x:Key="ListBox.Disabled.Border" Color="#FFD9D9D9" />
  43. <Style TargetType="{x:Type UI:SegmentControl}">
  44. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  45. <Setter Property="Padding" Value="-1,-1" />
  46. <Setter Property="Background" Value="{StaticResource ListBox.Static.Background}" />
  47. <Setter Property="BorderBrush" Value="{StaticResource ListBox.Static.Border}" />
  48. <Setter Property="BorderThickness" Value="1,1,1,1" />
  49. <Setter Property="Foreground" Value="Black" />
  50. <Setter Property="FontFamily" Value="微软雅黑" />
  51. <Setter Property="FontSize" Value="12" />
  52. <Setter Property="CornerRadius" Value="5" />
  53. <Setter Property="HorizontalAlignment" Value="Left" />
  54. <Setter Property="VerticalAlignment" Value="Center" />
  55. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
  56. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
  57. <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
  58. <Setter Property="ScrollViewer.PanningMode" Value="Both" />
  59. <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
  60. <Setter Property="VerticalContentAlignment" Value="Center" />
  61. <Setter Property="Template">
  62. <Setter.Value>
  63. <ControlTemplate TargetType="{x:Type UI:SegmentControl}">
  64. <Border
  65. x:Name="Bd"
  66. Background="{TemplateBinding Background}"
  67. BorderBrush="{TemplateBinding BorderBrush}"
  68. BorderThickness="{TemplateBinding BorderThickness}"
  69. CornerRadius="{TemplateBinding CornerRadius}"
  70. SnapsToDevicePixels="true"
  71. UseLayoutRounding="True">
  72. <ScrollViewer Padding="{TemplateBinding Padding}" Focusable="false">
  73. <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  74. </ScrollViewer>
  75. </Border>
  76. <ControlTemplate.Triggers>
  77. <Trigger Property="IsEnabled" Value="false">
  78. <Setter TargetName="Bd" Property="Background" Value="{StaticResource ListBox.Disabled.Background}" />
  79. <Setter TargetName="Bd" Property="BorderBrush" Value="{StaticResource ListBox.Disabled.Border}" />
  80. </Trigger>
  81. </ControlTemplate.Triggers>
  82. </ControlTemplate>
  83. </Setter.Value>
  84. </Setter>
  85. <Setter Property="ItemsPanel">
  86. <Setter.Value>
  87. <ItemsPanelTemplate>
  88. <StackPanel IsItemsHost="True" Orientation="Horizontal" />
  89. </ItemsPanelTemplate>
  90. </Setter.Value>
  91. </Setter>
  92. </Style>
  93. </ResourceDictionary>