ImageView.xaml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:fw="clr-namespace:FWindSoft.Wpf.Controls">
  4. <Style x:Key="{ComponentResourceKey
  5. TypeInTargetAssembly={x:Type fw:ImageView},
  6. ResourceId=DefaultStyle}"
  7. TargetType="{x:Type ListView}"
  8. BasedOn="{StaticResource {x:Type ListBox}}"
  9. >
  10. <Setter Property="ItemsPanel">
  11. <Setter.Value>
  12. <ItemsPanelTemplate>
  13. <WrapPanel Width="{Binding (FrameworkElement.ActualWidth),
  14. RelativeSource={RelativeSource
  15. AncestorType=ScrollContentPresenter}}"
  16. ItemWidth="{Binding (ListView.View).ItemWidth,
  17. RelativeSource={RelativeSource AncestorType=ListView}}"
  18. MinWidth="{Binding ItemWidth,
  19. RelativeSource={RelativeSource Self}}"
  20. ItemHeight="{Binding (ListView.View).ItemHeight,
  21. RelativeSource={RelativeSource AncestorType=ListView}}"/>
  22. </ItemsPanelTemplate>
  23. </Setter.Value>
  24. </Setter>
  25. </Style>
  26. <Style x:Key="{ComponentResourceKey TypeInTargetAssembly=
  27. {x:Type fw:ImageView},
  28. ResourceId=ItemContainerDefaultStyle}"
  29. TargetType="{x:Type ListViewItem}">
  30. <Setter Property="Background" Value="Transparent" />
  31. <Setter Property="HorizontalContentAlignment" Value="Center" />
  32. <Setter Property="VerticalContentAlignment" Value="Center" />
  33. <Setter Property="Padding" Value="0"/>
  34. <Setter Property="Margin" Value="1"/>
  35. <Setter Property="Template">
  36. <Setter.Value>
  37. <ControlTemplate TargetType="{x:Type ListViewItem}">
  38. <Border x:Name="Border" Margin="2,1,2,1" BorderThickness="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
  39. Background="AliceBlue" OpacityMask="#FF61E4E4">
  40. <Grid>
  41. <Grid.RowDefinitions>
  42. <RowDefinition Height="*"></RowDefinition>
  43. <RowDefinition Height="Auto"></RowDefinition>
  44. </Grid.RowDefinitions>
  45. <Image Margin="1" Cursor="Hand" Stretch="Fill" HorizontalAlignment="Center" Source="{Binding Path=(fw:ImageView.Image),Mode=OneWay,RelativeSource={RelativeSource TemplatedParent}}" >
  46. <Image.ToolTip >
  47. <TextBlock Text="{Binding Path=(fw:ImageView.ToolTip),Mode=OneWay,RelativeSource={RelativeSource TemplatedParent}}" />
  48. </Image.ToolTip>
  49. </Image>
  50. <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="1" Text="{Binding Path=(fw:ImageView.Display),Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
  51. </Grid>
  52. </Border>
  53. <ControlTemplate.Triggers>
  54. <Trigger Property="IsFocused" Value="True">
  55. <Setter Property="BorderBrush" Value="#1DE5E5" TargetName="Border" />
  56. </Trigger>
  57. <Trigger Property="IsMouseOver" Value="True">
  58. <Setter Property="BorderBrush" Value="#77E8E8" TargetName="Border" />
  59. </Trigger>
  60. <Trigger Property="IsFocused" Value="False">
  61. <Setter Property="BorderBrush" Value="#1DE5E5" TargetName="Border" />
  62. </Trigger>
  63. <Trigger Property="IsSelected" Value="False">
  64. <Setter Property="BorderBrush" Value="#919191" TargetName="Border" />
  65. </Trigger>
  66. </ControlTemplate.Triggers>
  67. </ControlTemplate>
  68. </Setter.Value>
  69. </Setter>
  70. </Style>
  71. </ResourceDictionary>