ListBox.xaml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. mc:Ignorable="d">
  7. <Style TargetType="{x:Type ListBox}">
  8. <Setter Property="Foreground" Value="{DynamicResource FG_Black}"/>
  9. <Setter Property="FontFamily" Value="Arial"/>
  10. <Setter Property="FontSize" Value="12"/>
  11. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
  12. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
  13. <Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
  14. <Setter Property="VerticalContentAlignment" Value="top"/>
  15. <Setter Property="Template">
  16. <Setter.Value>
  17. <ControlTemplate TargetType="{x:Type ListBox}">
  18. <Border x:Name="Bd" SnapsToDevicePixels="true">
  19. <ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}">
  20. <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  21. </ScrollViewer>
  22. </Border>
  23. <ControlTemplate.Triggers>
  24. <Trigger Property="IsEnabled" Value="false"/>
  25. <Trigger Property="IsGrouping" Value="true">
  26. <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
  27. </Trigger>
  28. </ControlTemplate.Triggers>
  29. </ControlTemplate>
  30. </Setter.Value>
  31. </Setter>
  32. </Style>
  33. <Style TargetType="{x:Type ListBoxItem}">
  34. <Setter Property="Background" Value="Transparent"/>
  35. <Setter Property="Margin" Value="0"/>
  36. <Setter Property="Padding" Value="0"/>
  37. <Setter Property="BorderThickness" Value="0"/>
  38. <Setter Property="Rectangle.StrokeThickness" Value="3"/>
  39. <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
  40. <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
  41. <Setter Property="Template">
  42. <Setter.Value>
  43. <ControlTemplate TargetType="{x:Type ListBoxItem}">
  44. <Border x:Name="Bd" SnapsToDevicePixels="true">
  45. <Grid>
  46. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Cursor="Hand" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  47. <Rectangle x:Name="Highlight" StrokeThickness="{TemplateBinding Rectangle.StrokeThickness}" Opacity="0"/>
  48. </Grid>
  49. </Border>
  50. <ControlTemplate.Triggers>
  51. <Trigger Property="IsSelected" Value="true">
  52. <Setter Property="Stroke" TargetName="Highlight" Value="Orange"/>
  53. <Setter Property="Opacity" TargetName="Highlight" Value="1"/>
  54. <Setter Property="Foreground" Value="{DynamicResource FG_Black}"/>
  55. </Trigger>
  56. <Trigger Property="IsEnabled" Value="false">
  57. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  58. </Trigger>
  59. </ControlTemplate.Triggers>
  60. </ControlTemplate>
  61. </Setter.Value>
  62. </Setter>
  63. </Style>
  64. <Style x:Key="Sepcial_ListBoxItem" TargetType="{x:Type ListBoxItem}">
  65. <Setter Property="Background" Value="Transparent"/>
  66. <Setter Property="Margin" Value="0"/>
  67. <Setter Property="Padding" Value="0"/>
  68. <Setter Property="BorderThickness" Value="0"/>
  69. <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
  70. <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
  71. <Setter Property="Template">
  72. <Setter.Value>
  73. <ControlTemplate TargetType="{x:Type ListBoxItem}">
  74. <Border x:Name="Bd" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
  75. <Grid>
  76. <Border x:Name="Highlight" BorderBrush="Black" BorderThickness="0" Background="{DynamicResource Listview_BG_Highlight}" Opacity="0"/>
  77. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Cursor="Hand" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  78. </Grid>
  79. </Border>
  80. <ControlTemplate.Triggers>
  81. <Trigger Property="IsSelected" Value="true">
  82. <Setter Property="Opacity" TargetName="Highlight" Value="1"/>
  83. <Setter Property="BorderThickness" TargetName="Highlight" Value="1"/>
  84. <Setter Property="Foreground" Value="{DynamicResource FG_White}"/>
  85. <Setter Property="Margin" TargetName="Highlight" Value="0,0,1,1"/>
  86. </Trigger>
  87. <Trigger Property="IsMouseOver" Value="True">
  88. <Setter Property="Opacity" TargetName="Highlight" Value="0.8"/>
  89. </Trigger>
  90. <Trigger Property="IsEnabled" Value="false">
  91. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  92. </Trigger>
  93. </ControlTemplate.Triggers>
  94. </ControlTemplate>
  95. </Setter.Value>
  96. </Setter>
  97. <Style.Triggers>
  98. <Trigger Property="ListBox.AlternationIndex" Value="0">
  99. <Setter Property="Background" Value="{DynamicResource Listview_BG_First}"/>
  100. </Trigger>
  101. <Trigger Property="ListBox.AlternationIndex" Value="1">
  102. <Setter Property="Background" Value="{DynamicResource Listview_BG_Second}"/>
  103. </Trigger>
  104. </Style.Triggers>
  105. </Style>
  106. <Style x:Key="NoSelection_ListBoxItem" TargetType="{x:Type ListBoxItem}">
  107. <Setter Property="Background" Value="Transparent"/>
  108. <Setter Property="Margin" Value="0"/>
  109. <Setter Property="Padding" Value="0"/>
  110. <Setter Property="BorderThickness" Value="0"/>
  111. <Setter Property="Rectangle.StrokeThickness" Value="3"/>
  112. <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
  113. <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
  114. <Setter Property="Template">
  115. <Setter.Value>
  116. <ControlTemplate TargetType="{x:Type ListBoxItem}">
  117. <Border x:Name="Bd" SnapsToDevicePixels="true">
  118. <Grid>
  119. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Cursor="Hand" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  120. <Rectangle x:Name="Highlight" StrokeThickness="{TemplateBinding Rectangle.StrokeThickness}" Opacity="0"/>
  121. </Grid>
  122. </Border>
  123. <ControlTemplate.Triggers>
  124. <Trigger Property="IsSelected" Value="true">
  125. <Setter Property="Stroke" TargetName="Highlight" Value="Transparent"/>
  126. <Setter Property="Opacity" TargetName="Highlight" Value="1"/>
  127. <Setter Property="Foreground" Value="{DynamicResource FG_Black}"/>
  128. </Trigger>
  129. <Trigger Property="IsEnabled" Value="false">
  130. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  131. </Trigger>
  132. </ControlTemplate.Triggers>
  133. </ControlTemplate>
  134. </Setter.Value>
  135. </Setter>
  136. </Style>
  137. </ResourceDictionary>