improve stepbar

This commit is contained in:
NaBian committed 2018-11-11 15:07:55 +08:00
1 parent bc2bd5413c
commit dec0d37b31
27 files changed
+591 -308

No files matched your search

@@ -0,0 +1,134 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../TextBlock.xaml"/>
<ResourceDictionary Source="../ProgressBar.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="StepBarItemBaseStyle" TargetType="controls:StepBarItem">
<Setter Property="Foreground" Value="{DynamicResource ThirdlyTextBrush}"/>
<Style.Triggers>
<Trigger Property="Status" Value="Complete">
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
</Trigger>
<Trigger Property="Status" Value="UnderWay">
<Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}"/>
</Trigger>
<Trigger Property="Status" Value="Waiting">
<Setter Property="Foreground" Value="{DynamicResource ThirdlyTextBrush}"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="StepBarItemHorizontalTop" BasedOn="{StaticResource StepBarItemBaseStyle}" TargetType="controls:StepBarItem">
<Setter Property="Margin" Value="10,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:StepBarItem">
<StackPanel>
<Border Background="{DynamicResource RegionBrush}" HorizontalAlignment="Center" CornerRadius="12" BorderThickness="2" BorderBrush="{TemplateBinding Foreground}" Height="24" MinWidth="24">
<TextBlock Foreground="{TemplateBinding Foreground}" Style="{StaticResource TextBlockDefaultThiLight}" Text="{Binding Index,RelativeSource={RelativeSource TemplatedParent}}"/>
</Border>
<ContentPresenter HorizontalAlignment="Center" ContentTemplate="{Binding ItemTemplate,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:StepBar}}" TextElement.Foreground="{TemplateBinding Foreground}" Margin="0,4,0,0"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="StepBarItemHorizontalBottom" BasedOn="{StaticResource StepBarItemBaseStyle}" TargetType="controls:StepBarItem">
<Setter Property="Margin" Value="10,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:StepBarItem">
<StackPanel>
<ContentPresenter HorizontalAlignment="Center" ContentTemplate="{Binding ItemTemplate,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:StepBar}}" TextElement.Foreground="{TemplateBinding Foreground}" Margin="0,0,0,4"/>
<Border Background="{DynamicResource RegionBrush}" HorizontalAlignment="Center" CornerRadius="12" BorderThickness="2" BorderBrush="{TemplateBinding Foreground}" Height="24" MinWidth="24">
<TextBlock Foreground="{TemplateBinding Foreground}" Style="{StaticResource TextBlockDefaultThiLight}" Text="{Binding Index,RelativeSource={RelativeSource TemplatedParent}}"/>
</Border>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="StepBarItemVerticalLeft" BasedOn="{StaticResource StepBarItemBaseStyle}" TargetType="controls:StepBarItem">
<Setter Property="Margin" Value="0, 10"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:StepBarItem">
<StackPanel Orientation="Horizontal">
<Border Background="{DynamicResource RegionBrush}" HorizontalAlignment="Center" CornerRadius="12" BorderThickness="2" BorderBrush="{TemplateBinding Foreground}" Height="24" MinWidth="24">
<TextBlock Foreground="{TemplateBinding Foreground}" Style="{StaticResource TextBlockDefaultThiLight}" Text="{Binding Index,RelativeSource={RelativeSource TemplatedParent}}"/>
</Border>
<StackPanel Margin="10,0,0,0">
<ContentPresenter HorizontalAlignment="Left" ContentTemplate="{Binding ItemTemplate,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:StepBar}}" TextElement.Foreground="{TemplateBinding Foreground}" Margin="0,4,0,0"/>
</StackPanel>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ItemsPanelTemplate x:Key="StepBarHorizontalItemsPanelTemplate">
<UniformGrid Rows="1"/>
</ItemsPanelTemplate>
<ItemsPanelTemplate x:Key="StepBarVerticalItemsPanelTemplate">
<UniformGrid Columns="1"/>
</ItemsPanelTemplate>
<ControlTemplate x:Key="StepBarHorizontalTopControlTemplate" TargetType="controls:StepBar">
<Grid>
<ProgressBar HorizontalAlignment="Center" Name="PART_ProgressBarBack" VerticalAlignment="Top" Margin="0,10,0,0" Style="{StaticResource ProgressBarFlat}" Background="{DynamicResource ThirdlyTextBrush}"/>
<ItemsPresenter/>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="StepBarHorizontalBottomControlTemplate" TargetType="controls:StepBar">
<Grid>
<ProgressBar HorizontalAlignment="Center" Name="PART_ProgressBarBack" VerticalAlignment="Bottom" Margin="0,0,0,10" Style="{StaticResource ProgressBarFlat}" Background="{DynamicResource ThirdlyTextBrush}"/>
<ItemsPresenter VerticalAlignment="Bottom"/>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="StepBarVerticalLeftControlTemplate" TargetType="controls:StepBar">
<Grid>
<ProgressBar Orientation="Vertical" Width="4" HorizontalAlignment="Left" Name="PART_ProgressBarBack" VerticalAlignment="Center" Margin="10,0,0,0" Style="{StaticResource ProgressBarFlat}" Background="{DynamicResource ThirdlyTextBrush}" RenderTransformOrigin="0.5,0.5">
<ProgressBar.RenderTransform>
<TransformGroup>
<RotateTransform Angle="180"/>
</TransformGroup>
</ProgressBar.RenderTransform>
</ProgressBar>
<ItemsPresenter/>
</Grid>
</ControlTemplate>
<Style x:Key="StepBarBaseStyle" TargetType="controls:StepBar">
<Setter Property="ItemContainerStyle" Value="{StaticResource StepBarItemHorizontalTop}"/>
<Setter Property="Template" Value="{StaticResource StepBarHorizontalTopControlTemplate}"/>
<Setter Property="ItemsPanel" Value="{StaticResource StepBarHorizontalItemsPanelTemplate}"/>
<Style.Triggers>
<Trigger Property="Dock" Value="Left">
<Setter Property="ItemContainerStyle" Value="{StaticResource StepBarItemVerticalLeft}"/>
<Setter Property="Template" Value="{StaticResource StepBarVerticalLeftControlTemplate}"/>
<Setter Property="ItemsPanel" Value="{StaticResource StepBarVerticalItemsPanelTemplate}"/>
</Trigger>
<Trigger Property="Dock" Value="Bottom">
<Setter Property="ItemContainerStyle" Value="{StaticResource StepBarItemHorizontalBottom}"/>
<Setter Property="Template" Value="{StaticResource StepBarHorizontalBottomControlTemplate}"/>
<Setter Property="ItemsPanel" Value="{StaticResource StepBarHorizontalItemsPanelTemplate}"/>
</Trigger>
<Trigger Property="Dock" Value="Right">
<Setter Property="FlowDirection" Value="RightToLeft"/>
<Setter Property="ItemContainerStyle" Value="{StaticResource StepBarItemVerticalLeft}"/>
<Setter Property="Template" Value="{StaticResource StepBarVerticalLeftControlTemplate}"/>
<Setter Property="ItemsPanel" Value="{StaticResource StepBarVerticalItemsPanelTemplate}"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
+10 -3
View File
@@ -206,11 +206,18 @@
<Grid x:Name="TemplateRoot" SnapsToDevicePixels="true">
<Rectangle x:Name="PART_Track" Fill="{TemplateBinding Background}" StrokeThickness="0" Stroke="{TemplateBinding BorderBrush}"/>
<Decorator x:Name="PART_Indicator" HorizontalAlignment="Left">
<Grid x:Name="Foreground">
<Rectangle x:Name="Indicator" Fill="{TemplateBinding Foreground}"/>
</Grid>
<Rectangle x:Name="Indicator" Fill="{TemplateBinding Foreground}"/>
</Decorator>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="LayoutTransform" TargetName="TemplateRoot">
<Setter.Value>
<RotateTransform Angle="-90"/>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
+2 -32
View File
@@ -2,39 +2,9 @@
xmlns:controls="clr-namespace:HandyControl.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="TextBlock.xaml"/>
<ResourceDictionary Source="ProgressBar.xaml"/>
<ResourceDictionary Source="Base/StepBarBaseStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="controls:StepItem">
<Setter Property="Foreground" Value="{DynamicResource ThirdlyTextBrush}"/>
<Setter Property="Margin" Value="10,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:StepItem">
<StackPanel>
<Border Background="{DynamicResource RegionBrush}" HorizontalAlignment="Center" CornerRadius="12" BorderThickness="2" BorderBrush="{TemplateBinding Foreground}" Height="24" MinWidth="24">
<TextBlock Foreground="{TemplateBinding Foreground}" Style="{StaticResource TextBlockDefaultThiLight}" Text="{Binding Index,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:StepItem}}"/>
</Border>
<TextBlock Margin="0,10,0,0" Foreground="{TemplateBinding Foreground}" Style="{StaticResource TextBlockSubTitleBold}" Text="{TemplateBinding IndexStr}"/>
<TextBlock Foreground="{TemplateBinding Foreground}" Margin="0,4,0,0" Style="{StaticResource TextBlockDefaultThiLight}" Text="{TemplateBinding Title}"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="controls:StepBar">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:StepBar">
<Grid>
<ProgressBar HorizontalAlignment="Center" Name="PART_ProgressBarBack" VerticalAlignment="Top" Margin="0,10,0,0" Style="{StaticResource ProgressBarFlat}" Background="{DynamicResource ThirdlyTextBrush}"/>
<UniformGrid Name="PART_UniformGridMain" Rows="1"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style BasedOn="{StaticResource StepBarBaseStyle}" TargetType="controls:StepBar"/>
</ResourceDictionary>