| 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.Base" xmlns:button="clr-namespace:UI.Controls.Button"> |
| 4 | <Style TargetType="{x:Type local:IconSelect}"> |
| 5 | <Setter Property="SnapsToDevicePixels" |
| 6 | Value="true" /> |
| 7 | <Setter Property="Background" Value="Transparent"/> |
| 8 | <Setter Property="Width" Value="80"/> |
| 9 | <Setter Property="Height" Value="80"/> |
| 10 | |
| 11 | <Setter Property="Template"> |
| 12 | <Setter.Value> |
| 13 | <ControlTemplate TargetType="{x:Type local:IconSelect}"> |
| 14 | <Border Background="{TemplateBinding Background}" SnapsToDevicePixels="True" BorderBrush="#f7f8fa" CornerRadius="10" BorderThickness="2" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"> |
| 15 | <Border.InputBindings> |
| 16 | <MouseBinding Gesture="LeftClick" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:IconSelect}}, Path=ShowSelectCommand}"/> |
| 17 | </Border.InputBindings> |
| 18 | <Grid> |
| 19 | <local:Img HorizontalAlignment="Center" VerticalAlignment="Center" URL="{TemplateBinding URL}" Width="30" Height="30"/> |
| 20 | |
| 21 | <Popup |
| 22 | x:Name="Popup" |
| 23 | Placement="Bottom" |
| 24 | IsOpen="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:IconSelect}}, Path=IsOpen,Mode=TwoWay}" AllowsTransparency="True" |
| 25 | > |
| 26 | <Border |
| 27 | x:Name="SelectContainer" |
| 28 | CornerRadius="10" |
| 29 | BorderBrush="{DynamicResource PopupBorderBrush}" |
| 30 | BorderThickness="1" |
| 31 | Background="{DynamicResource PopupBackgroundBrush}" Padding="10" Width="275" MaxHeight="300" Margin="10"> |
| 32 | <Border.Effect> |
| 33 | <DropShadowEffect BlurRadius="10" ShadowDepth="2" Direction="315" Color="Gray" Opacity=".3"/> |
| 34 | </Border.Effect> |
| 35 | <Grid> |
| 36 | <Grid.RowDefinitions> |
| 37 | <RowDefinition Height="auto"/> |
| 38 | <RowDefinition Height="*"/> |
| 39 | <RowDefinition Height="auto"/> |
| 40 | </Grid.RowDefinitions> |
| 41 | |
| 42 | <TextBlock Text="选择图标" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="{DynamicResource DefaultTextBrush}"/> |
| 43 | |
| 44 | <ScrollViewer Grid.Row="1"> |
| 45 | <ListView Grid.Row="1" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:IconSelect}}, Path=Icons}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:IconSelect}}, Path=URL,Mode=TwoWay}" Margin="0,10,0,0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" > |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | <ListBox.Resources> |
| 53 | <Style TargetType="{x:Type ListView}"> |
| 54 | <Setter Property="OverridesDefaultStyle" Value="True"/> |
| 55 | |
| 56 | <Setter Property="Template"> |
| 57 | <Setter.Value> |
| 58 | <ControlTemplate TargetType="{x:Type ListView}"> |
| 59 | <Border> |
| 60 | <ItemsPresenter /> |
| 61 | </Border> |
| 62 | </ControlTemplate> |
| 63 | </Setter.Value> |
| 64 | </Setter> |
| 65 | </Style> |
| 66 | <Style TargetType="{x:Type ListViewItem}"> |
| 67 | <Setter Property="OverridesDefaultStyle" Value="True"/> |
| 68 | <Setter Property="Foreground" Value="#1a1a1a"/> |
| 69 | |
| 70 | <Setter Property="Template"> |
| 71 | <Setter.Value> |
| 72 | <ControlTemplate TargetType="{x:Type ListViewItem}"> |
| 73 | <Border BorderBrush="Transparent" BorderThickness="2" x:Name="Border" Background="Transparent" Margin="0,0,0,0" Padding="0" Width="35" Height="35" CornerRadius="5"> |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | <ContentPresenter x:Name="Icon" VerticalAlignment="Center" HorizontalAlignment="Center" RenderTransformOrigin=".5,.5" > |
| 80 | <ContentPresenter.RenderTransform> |
| 81 | <ScaleTransform ScaleX=".7" ScaleY=".7"/> |
| 82 | </ContentPresenter.RenderTransform> |
| 83 | </ContentPresenter> |
| 84 | |
| 85 | </Border> |
| 86 | <ControlTemplate.Triggers> |
| 87 | |
| 88 | <Trigger Property="IsMouseOver" Value="True"> |
| 89 | <Setter TargetName="Border" Property="Background" Value="{DynamicResource HoverBackgroundBrush}"/> |
| 90 | |
| 91 | |
| 92 | </Trigger> |
| 93 | <Trigger Property="IsSelected" Value="True"> |
| 94 | <Setter TargetName="Border" Property="Background" Value="{DynamicResource ThemeBrush}"/> |
| 95 | <Setter Property="Foreground" Value="White"/> |
| 96 | |
| 97 | |
| 98 | |
| 99 | </Trigger> |
| 100 | <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True"> |
| 101 | <DataTrigger.EnterActions> |
| 102 | <BeginStoryboard> |
| 103 | <Storyboard> |
| 104 | <DoubleAnimation Storyboard.TargetProperty="(ContentPresenter.RenderTransform). |
| 105 | (ScaleTransform.ScaleX)" |
| 106 | Storyboard.TargetName="Icon" Duration="00:00:0.3" To="1"/> |
| 107 | <DoubleAnimation Storyboard.TargetProperty="(ContentPresenter.RenderTransform). |
| 108 | (ScaleTransform.ScaleY)" |
| 109 | Storyboard.TargetName="Icon" Duration="00:00:0.3" To="1"/> |
| 110 | </Storyboard> |
| 111 | </BeginStoryboard> |
| 112 | </DataTrigger.EnterActions> |
| 113 | <DataTrigger.ExitActions> |
| 114 | <BeginStoryboard> |
| 115 | <Storyboard> |
| 116 | <DoubleAnimation Storyboard.TargetProperty="(ContentPresenter.RenderTransform). |
| 117 | (ScaleTransform.ScaleX)" |
| 118 | Storyboard.TargetName="Icon" Duration="00:00:0.3" To=".7"/> |
| 119 | <DoubleAnimation Storyboard.TargetProperty="(ContentPresenter.RenderTransform). |
| 120 | (ScaleTransform.ScaleY)" |
| 121 | Storyboard.TargetName="Icon" Duration="00:00:0.3" To=".7"/> |
| 122 | </Storyboard> |
| 123 | </BeginStoryboard> |
| 124 | </DataTrigger.ExitActions> |
| 125 | </DataTrigger> |
| 126 | </ControlTemplate.Triggers> |
| 127 | </ControlTemplate> |
| 128 | </Setter.Value> |
| 129 | </Setter> |
| 130 | |
| 131 | </Style> |
| 132 | </ListBox.Resources> |
| 133 | <ListBox.ItemsPanel> |
| 134 | <ItemsPanelTemplate> |
| 135 | <WrapPanel/> |
| 136 | </ItemsPanelTemplate> |
| 137 | </ListBox.ItemsPanel> |
| 138 | <ListView.ItemTemplate> |
| 139 | <DataTemplate> |
| 140 | |
| 141 | <WrapPanel Orientation="Horizontal"> |
| 142 | <Border > |
| 143 | |
| 144 | <local:Img URL="{Binding}" Width="25" Height="25"/> |
| 145 | |
| 146 | </Border> |
| 147 | |
| 148 | </WrapPanel> |
| 149 | </DataTemplate> |
| 150 | </ListView.ItemTemplate> |
| 151 | </ListView> |
| 152 | </ScrollViewer> |
| 153 | <button:Button Grid.Row="2" Icon="Photo" HorizontalAlignment="Right" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:IconSelect}}, Path=FileSelectCommand}" Content="自定义图片" Width="120"/> |
| 154 | </Grid> |
| 155 | </Border> |
| 156 | |
| 157 | </Popup> |
| 158 | </Grid> |
| 159 | </Border> |
| 160 | <ControlTemplate.Triggers> |
| 161 | |
| 162 | <Trigger Property="IsMouseOver" Value="True"> |
| 163 | <Setter Property="Background" Value="{DynamicResource HoverBackgroundBrush}"/> |
| 164 | </Trigger> |
| 165 | </ControlTemplate.Triggers> |
| 166 | </ControlTemplate> |
| 167 | </Setter.Value> |
| 168 | </Setter> |
| 169 | </Style> |
| 170 | </ResourceDictionary> |