ListBoxItemStyle.xaml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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="Background" Value="Transparent"/>
  23. <Setter Property="BorderBrush" Value="Transparent"/>
  24. <Setter Property="BorderThickness" Value="1"/>
  25. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
  26. <Setter Property="Template">
  27. <Setter.Value>
  28. <ControlTemplate TargetType="{x:Type ListBoxItem}">
  29. <Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
  30. <StackPanel HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  31. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  32. VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
  33. <Viewbox Margin="0,5,0,0" Stretch="Uniform" Width="{Binding ThumbnailWidth}" Height="{Binding ThumbnailHeight}">
  34. <Border x:Name="imageOuterBorder" BorderThickness="2" BorderBrush="Transparent">
  35. <Border x:Name="imageInnerBorder" BorderThickness="2" BorderBrush="Black">
  36. <Image Source="{Binding Path=ImageData.Source}" Margin="0,0,5,0" Width="{Binding ImageWidth}" Height="{Binding ImageHeight}"></Image>
  37. </Border>
  38. </Border>
  39. </Viewbox>
  40. <Border x:Name="pageNumberBorder" Width="22" Height="16" Margin="0,8,0,0">
  41. <TextBlock x:Name="pageNumberText" Text="{Binding ShowPageText}" HorizontalAlignment="Center" FontSize="11" VerticalAlignment="Center"></TextBlock>
  42. </Border>
  43. </StackPanel>
  44. </Border>
  45. <ControlTemplate.Triggers>
  46. <MultiTrigger>
  47. <MultiTrigger.Conditions>
  48. <Condition Property="IsMouseOver" Value="True"/>
  49. </MultiTrigger.Conditions>
  50. <Setter Property="BorderBrush" TargetName="imageOuterBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  51. <Setter Property="BorderBrush" TargetName="imageInnerBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  52. <Setter Property="Background" TargetName="pageNumberBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  53. <Setter Property="Foreground" TargetName="pageNumberText" Value="{StaticResource Item.Selected.Text}"/>
  54. </MultiTrigger>
  55. <MultiTrigger>
  56. <MultiTrigger.Conditions>
  57. <Condition Property="Selector.IsSelectionActive" Value="False"/>
  58. <Condition Property="IsSelected" Value="True"/>
  59. </MultiTrigger.Conditions>
  60. <Setter Property="BorderBrush" TargetName="imageOuterBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  61. <Setter Property="BorderBrush" TargetName="imageInnerBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  62. <Setter Property="Background" TargetName="pageNumberBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  63. <Setter Property="Foreground" TargetName="pageNumberText" Value="{StaticResource Item.Selected.Text}"/>
  64. </MultiTrigger>
  65. <MultiTrigger>
  66. <MultiTrigger.Conditions>
  67. <Condition Property="Selector.IsSelectionActive" Value="True"/>
  68. <Condition Property="IsSelected" Value="True"/>
  69. </MultiTrigger.Conditions>
  70. <Setter Property="BorderBrush" TargetName="imageOuterBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  71. <Setter Property="BorderBrush" TargetName="imageInnerBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  72. <Setter Property="Background" TargetName="pageNumberBorder" Value="{StaticResource Item.MouseOver.Border}"/>
  73. <Setter Property="Foreground" TargetName="pageNumberText" Value="{StaticResource Item.Selected.Text}"/>
  74. </MultiTrigger>
  75. <Trigger Property="IsEnabled" Value="False">
  76. <Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  77. </Trigger>
  78. </ControlTemplate.Triggers>
  79. </ControlTemplate>
  80. </Setter.Value>
  81. </Setter>
  82. </Style>
  83. <ControlTemplate x:Key="ListBoxItemControlTemplate" TargetType="{x:Type ListBoxItem}">
  84. <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
  85. <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  86. </Border>
  87. <ControlTemplate.Triggers>
  88. <MultiTrigger>
  89. <MultiTrigger.Conditions>
  90. <Condition Property="IsMouseOver" Value="True"/>
  91. </MultiTrigger.Conditions>
  92. <Setter Property="Background" TargetName="Bd" Value="#1A000000"/>
  93. <Setter Property="BorderBrush" TargetName="Bd" Value="Transparent"/>
  94. </MultiTrigger>
  95. <MultiTrigger>
  96. <MultiTrigger.Conditions>
  97. <Condition Property="Selector.IsSelectionActive" Value="False"/>
  98. <Condition Property="IsSelected" Value="True"/>
  99. </MultiTrigger.Conditions>
  100. <Setter Property="Background" TargetName="Bd" Value="#1A477EDE"/>
  101. <Setter Property="BorderBrush" TargetName="Bd" Value="Transparent"/>
  102. </MultiTrigger>
  103. <MultiTrigger>
  104. <MultiTrigger.Conditions>
  105. <Condition Property="Selector.IsSelectionActive" Value="True"/>
  106. <Condition Property="IsSelected" Value="True"/>
  107. </MultiTrigger.Conditions>
  108. <Setter Property="Background" TargetName="Bd" Value="#1A477EDE"/>
  109. <Setter Property="BorderBrush" TargetName="Bd" Value="Transparent"/>
  110. </MultiTrigger>
  111. <Trigger Property="IsEnabled" Value="False">
  112. <Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  113. </Trigger>
  114. </ControlTemplate.Triggers>
  115. </ControlTemplate>
  116. </ResourceDictionary>