功能更新
This commit is contained in:
180
Melskin/Controls/UploadArea.xaml
Normal file
180
Melskin/Controls/UploadArea.xaml
Normal file
@@ -0,0 +1,180 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:controls="clr-namespace:Melskin.Controls"
|
||||
xmlns:converters="clr-namespace:Melskin.Converters"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Style TargetType="Button" x:Key="DeleteButtonStyle">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<controls:IconElement Foreground="{TemplateBinding Foreground}" Symbol="Delete" />
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ErrorBrush}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="{x:Type controls:UploadArea}">
|
||||
<Setter Property="AllowDrop" Value="True" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="#bec8e4" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<!--<Setter Property="Padding" Value="8" />-->
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type controls:UploadArea}">
|
||||
<Grid>
|
||||
<StackPanel>
|
||||
<!-- 上传区域 -->
|
||||
<Border
|
||||
Background="{DynamicResource ControlBackgroundNormalBrush}"
|
||||
Cursor="Hand"
|
||||
SnapsToDevicePixels="True"
|
||||
x:Name="PART_DropArea">
|
||||
<Border.InputBindings>
|
||||
<MouseBinding Command="{Binding SelectCommand, RelativeSource={RelativeSource TemplatedParent}}" MouseAction="LeftClick" />
|
||||
</Border.InputBindings>
|
||||
|
||||
<Border
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="4"
|
||||
Padding="16"
|
||||
x:Name="DropAreaBorder">
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<controls:IconElement
|
||||
FontSize="80"
|
||||
Foreground="{DynamicResource PrimaryNormalBrush}"
|
||||
Padding="-6"
|
||||
Symbol="Upload" />
|
||||
<TextBlock
|
||||
FontSize="14"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="{DynamicResource TextPrimaryBrush}"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0"
|
||||
Text="{TemplateBinding HintText}" />
|
||||
<TextBlock
|
||||
FontSize="12"
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,4,0,0"
|
||||
Text="{TemplateBinding Description}"
|
||||
TextWrapping="WrapWithOverflow" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Border>
|
||||
|
||||
<!-- 已选列表 -->
|
||||
<ItemsControl
|
||||
ItemsSource="{TemplateBinding FileList}"
|
||||
Margin="0,8,0,0"
|
||||
x:Name="ItemList">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type controls:UploadFileItem}">
|
||||
<Border
|
||||
Background="{DynamicResource ControlBackgroundNormalBrush}"
|
||||
BorderBrush="{DynamicResource BorderNormalBrush}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="4"
|
||||
Margin="0,4"
|
||||
Padding="8"
|
||||
x:Name="ItemBorder">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 文件图标 -->
|
||||
<controls:IconElement
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"
|
||||
Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
Symbol="Files" />
|
||||
|
||||
<TextBlock
|
||||
Foreground="{DynamicResource TextPrimaryBrush}"
|
||||
Grid.Column="1"
|
||||
Text="{Binding FileName}"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
VerticalAlignment="Center" />
|
||||
|
||||
<Button
|
||||
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:UploadArea}}, Path=RemoveItemCommand}"
|
||||
CommandParameter="{Binding}"
|
||||
Grid.Column="2"
|
||||
Style="{StaticResource DeleteButtonStyle}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<DataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding FileList, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={x:Static converters:NullOrEmptyConverter.Instance}}">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
</DataTrigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" TargetName="ItemBorder" Value="{DynamicResource ControlBackgroundHoverBrush}" />
|
||||
</Trigger>
|
||||
<!-- 可以根据文件状态显示不同样式 -->
|
||||
<DataTrigger Binding="{Binding Status}" Value="Error">
|
||||
<!--<Setter Property="Foreground" Value="#ff4d4f"/>-->
|
||||
<Setter Property="BorderBrush" TargetName="ItemBorder" Value="{DynamicResource ErrorBrush}" />
|
||||
</DataTrigger>
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
</StackPanel>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal" />
|
||||
<VisualState x:Name="Disabled">
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.2"
|
||||
Storyboard.TargetName="PART_DropArea"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0.5" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="DragDropStates">
|
||||
<VisualState x:Name="DragLeave" />
|
||||
<VisualState x:Name="DragOver">
|
||||
<Storyboard>
|
||||
<ColorAnimation
|
||||
Duration="0:0:0.2"
|
||||
Storyboard.TargetName="DropAreaBorder"
|
||||
Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)"
|
||||
To="#4098FF" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user