ListBoxItemStyle.xaml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  3. <Style x:Key="FocusVisual">
  4. <Setter Property="Control.Template">
  5. <Setter.Value>
  6. <ControlTemplate>
  7. <Rectangle Margin="2" StrokeDashArray="1 2" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" SnapsToDevicePixels="true" StrokeThickness="1"/>
  8. </ControlTemplate>
  9. </Setter.Value>
  10. </Setter>
  11. </Style>
  12. <SolidColorBrush x:Key="Item.MouseOver.Background" Color="#1F26A0DA"/>
  13. <SolidColorBrush x:Key="Item.MouseOver.Border" Color="#1460F3"/>
  14. <SolidColorBrush x:Key="Item.SelectedActive.Background" Color="#3D26A0DA"/>
  15. <SolidColorBrush x:Key="Item.SelectedActive.Border" Color="#FF26A0DA"/>
  16. <SolidColorBrush x:Key="Item.SelectedInactive.Background" Color="#3DDADADA"/>
  17. <SolidColorBrush x:Key="Item.SelectedInactive.Border" Color="#FFDADADA"/>
  18. <SolidColorBrush x:Key="Item.Selected.Text" Color="#FFFFFF"/>
  19. <Style x:Key="ThumbnailListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
  20. <Setter Property="SnapsToDevicePixels" Value="True"/>
  21. <Setter Property="Padding" Value="4,1"/>
  22. <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
  23. <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
  24. <Setter Property="Background" Value="Transparent"/>
  25. <Setter Property="BorderBrush" Value="Transparent"/>
  26. <Setter Property="BorderThickness" Value="1"/>
  27. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
  28. <Setter Property="Template">
  29. <Setter.Value>
  30. <ControlTemplate TargetType="{x:Type ListBoxItem}">
  31. <Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
  32. <StackPanel HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  33. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  34. VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
  35. <Viewbox Margin="0,5,0,0" Stretch="Uniform" Width="{Binding ThumbnailWidth}" Height="{Binding ThumbnailHeight}">
  36. <Border x:Name="imageOuterBorder" BorderThickness="2" BorderBrush="Transparent">
  37. <Border x:Name="imageInnerBorder" BorderThickness="2" BorderBrush="Black">
  38. <Image Source="{Binding Path=ImageData.Source}" Margin="0,0,5,0" Width="{Binding ImageWidth}" Height="{Binding ImageHeight}"></Image>
  39. </Border>
  40. </Border>
  41. </Viewbox>
  42. <Border x:Name="pageNumberBorder" Width="22" Height="16" Margin="0,8,0,0">
  43. <TextBlock x:Name="pageNumberText" Text="{Binding ShowPageText}" HorizontalAlignment="Center" FontSize="11" VerticalAlignment="Center"></TextBlock>
  44. </Border>
  45. </StackPanel>
  46. </Border>
  47. <ControlTemplate.Triggers>
  48. <MultiTrigger>
  49. <MultiTrigger.Conditions>
  50. <Condition Property="IsMouseOver" Value="True"/>
  51. </MultiTrigger.Conditions>
  52. <Setter Property="BorderBrush" TargetName="imageOuterBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  53. <Setter Property="BorderBrush" TargetName="imageInnerBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  54. <Setter Property="Background" TargetName="pageNumberBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  55. <Setter Property="Foreground" TargetName="pageNumberText" Value="{StaticResource Item.Selected.Text}"/>
  56. </MultiTrigger>
  57. <MultiTrigger>
  58. <MultiTrigger.Conditions>
  59. <Condition Property="Selector.IsSelectionActive" Value="False"/>
  60. <Condition Property="IsSelected" Value="True"/>
  61. </MultiTrigger.Conditions>
  62. <Setter Property="BorderBrush" TargetName="imageOuterBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  63. <Setter Property="BorderBrush" TargetName="imageInnerBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  64. <Setter Property="Background" TargetName="pageNumberBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  65. <Setter Property="Foreground" TargetName="pageNumberText" Value="{StaticResource Item.Selected.Text}"/>
  66. </MultiTrigger>
  67. <MultiTrigger>
  68. <MultiTrigger.Conditions>
  69. <Condition Property="Selector.IsSelectionActive" Value="True"/>
  70. <Condition Property="IsSelected" Value="True"/>
  71. </MultiTrigger.Conditions>
  72. <Setter Property="BorderBrush" TargetName="imageOuterBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  73. <Setter Property="BorderBrush" TargetName="imageInnerBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  74. <Setter Property="Background" TargetName="pageNumberBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  75. <Setter Property="Foreground" TargetName="pageNumberText" Value="{StaticResource Item.Selected.Text}"/>
  76. </MultiTrigger>
  77. <Trigger Property="IsEnabled" Value="False">
  78. <Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  79. </Trigger>
  80. </ControlTemplate.Triggers>
  81. </ControlTemplate>
  82. </Setter.Value>
  83. </Setter>
  84. </Style>
  85. <ControlTemplate x:Key="ListBoxItemControlTemplate" TargetType="{x:Type ListBoxItem}">
  86. <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
  87. <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  88. </Border>
  89. <ControlTemplate.Triggers>
  90. <MultiTrigger>
  91. <MultiTrigger.Conditions>
  92. <Condition Property="IsMouseOver" Value="True"/>
  93. </MultiTrigger.Conditions>
  94. <Setter Property="Background" TargetName="Bd" Value="#1A000000"/>
  95. <Setter Property="BorderBrush" TargetName="Bd" Value="Transparent"/>
  96. </MultiTrigger>
  97. <MultiTrigger>
  98. <MultiTrigger.Conditions>
  99. <Condition Property="Selector.IsSelectionActive" Value="False"/>
  100. <Condition Property="IsSelected" Value="True"/>
  101. </MultiTrigger.Conditions>
  102. <Setter Property="Background" TargetName="Bd" Value="#1A477EDE"/>
  103. <Setter Property="BorderBrush" TargetName="Bd" Value="Transparent"/>
  104. </MultiTrigger>
  105. <MultiTrigger>
  106. <MultiTrigger.Conditions>
  107. <Condition Property="Selector.IsSelectionActive" Value="True"/>
  108. <Condition Property="IsSelected" Value="True"/>
  109. </MultiTrigger.Conditions>
  110. <Setter Property="Background" TargetName="Bd" Value="#1A477EDE"/>
  111. <Setter Property="BorderBrush" TargetName="Bd" Value="Transparent"/>
  112. </MultiTrigger>
  113. <Trigger Property="IsEnabled" Value="False">
  114. <Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  115. </Trigger>
  116. </ControlTemplate.Triggers>
  117. </ControlTemplate>
  118. </ResourceDictionary>