| 1 | <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 2 | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 3 | xmlns:local="clr-namespace:UI.Controls.Select" xmlns:base="clr-namespace:UI.Controls.Base"> |
| 4 | |
| 5 | |
| 6 | <Style TargetType="{x:Type local:ImageSelect}"> |
| 7 | <Setter Property="SnapsToDevicePixels" |
| 8 | Value="True" /> |
| 9 | |
| 10 | <Setter Property="Background" Value="Transparent"/> |
| 11 | <Setter Property="ToolTip" Value="选择图片"/> |
| 12 | |
| 13 | <Setter Property="Template"> |
| 14 | <Setter.Value> |
| 15 | <ControlTemplate TargetType="{x:Type local:ImageSelect}"> |
| 16 | <Border SnapsToDevicePixels="True" Background="{TemplateBinding Background}" HorizontalAlignment="Left" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"> |
| 17 | <Border.InputBindings> |
| 18 | <MouseBinding Gesture="LeftClick" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:ImageSelect}}, Path=SelectCommand}"/> |
| 19 | </Border.InputBindings> |
| 20 | <Grid> |
| 21 | <Border x:Name="Choose" Background="#f7f8fa" Padding="20" CornerRadius="10"> |
| 22 | <Grid HorizontalAlignment="Center"> |
| 23 | <Grid.RowDefinitions> |
| 24 | <RowDefinition Height="*"/> |
| 25 | <RowDefinition Height="*"/> |
| 26 | </Grid.RowDefinitions> |
| 27 | <base:Icon IconType="Photo" Foreground="#2b20d9" VerticalAlignment="Center" HorizontalAlignment="Center"/> |
| 28 | |
| 29 | <TextBlock Text="选择图片" Grid.Row="1" Margin="0,10,0,0"/> |
| 30 | </Grid> |
| 31 | </Border> |
| 32 | <Border x:Name="Img" BorderBrush="#f7f8fa" BorderThickness="1" CornerRadius="10" Padding="10"> |
| 33 | <base:Img URL="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:ImageSelect}}, Path=URL,Mode=TwoWay}" Width="{TemplateBinding ImageWidth}" Height="{TemplateBinding ImageHeight}"/> |
| 34 | </Border> |
| 35 | |
| 36 | </Grid> |
| 37 | </Border> |
| 38 | <ControlTemplate.Triggers> |
| 39 | <Trigger Property="IsMouseOver" Value="True"> |
| 40 | <Setter Property="Background" TargetName="Choose" Value="#FFE8E6FF"/> |
| 41 | </Trigger> |
| 42 | <Trigger Property="IsSelected" Value="True"> |
| 43 | <Setter Property="Visibility" TargetName="Img" Value="Visible"/> |
| 44 | <Setter Property="Visibility" TargetName="Choose" Value="Collapsed"/> |
| 45 | </Trigger> |
| 46 | <Trigger Property="IsSelected" Value="False"> |
| 47 | <Setter Property="Visibility" TargetName="Img" Value="Collapsed"/> |
| 48 | <Setter Property="Visibility" TargetName="Choose" Value="Visible"/> |
| 49 | </Trigger> |
| 50 | </ControlTemplate.Triggers> |
| 51 | </ControlTemplate> |
| 52 | </Setter.Value> |
| 53 | </Setter> |
| 54 | </Style> |
| 55 | </ResourceDictionary> |