|
1 | 1 | --- |
2 | | -title: 建设中 |
| 2 | +title: StepBar 步骤条 |
3 | 3 | --- |
4 | 4 |
|
5 | | -建设中 |
| 5 | +引导用户按照流程完成任务的分步导航条. |
| 6 | + |
| 7 | +```cs |
| 8 | +[StyleTypedProperty(Property = "ItemContainerStyle", StyleTargetType = typeof(StepBarItem))] |
| 9 | +[DefaultEvent("StepChanged")] |
| 10 | +[TemplatePart(Name = ElementProgressBarBack, Type = typeof(ProgressBar))] |
| 11 | +public class StepBar : ItemsControl |
| 12 | +``` |
| 13 | + |
| 14 | +# 属性 |
| 15 | + |
| 16 | +|属性|描述|默认值|备注| |
| 17 | +|-|-|-|-| |
| 18 | +|StepIndex|当前步骤序号|0|| |
| 19 | +|Dock|步骤条顶靠方式|Dock.Top||| |
| 20 | + |
| 21 | +# 方法 |
| 22 | + |
| 23 | +|名称|说明| |
| 24 | +|-|-| |
| 25 | +| Next( ) | 跳转到下一步 | |
| 26 | +| Prev( ) | 跳转到上一步 | |
| 27 | + |
| 28 | +# 事件 |
| 29 | + |
| 30 | +|名称|说明| |
| 31 | +|-|-| |
| 32 | +| StepChanged | 步骤改变时触发 | |
| 33 | + |
| 34 | +# 案例 |
| 35 | + |
| 36 | +```xml |
| 37 | +<Grid Margin="32"> |
| 38 | + <Grid.RowDefinitions> |
| 39 | + <RowDefinition Height="Auto"/> |
| 40 | + <RowDefinition Height="Auto"/> |
| 41 | + <RowDefinition Height="Auto"/> |
| 42 | + <RowDefinition Height="Auto"/> |
| 43 | + </Grid.RowDefinitions> |
| 44 | + <Grid.ColumnDefinitions> |
| 45 | + <ColumnDefinition/> |
| 46 | + <ColumnDefinition/> |
| 47 | + </Grid.ColumnDefinitions> |
| 48 | + <hc:StepBar Grid.ColumnSpan="2" StepIndex="{Binding StepIndex}"> |
| 49 | + <hc:StepBarItem Content="{ex:Lang Key={x:Static langs:LangKeys.Register}}"/> |
| 50 | + <hc:StepBarItem Content="{ex:Lang Key={x:Static langs:LangKeys.BasicInfo}}"/> |
| 51 | + <hc:StepBarItem Content="{ex:Lang Key={x:Static langs:LangKeys.UploadFile}}"/> |
| 52 | + <hc:StepBarItem Content="{ex:Lang Key={x:Static langs:LangKeys.Complete}}"/> |
| 53 | + </hc:StepBar> |
| 54 | + <StackPanel Margin="0,32" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Center"> |
| 55 | + <Button Command="{Binding PrevCmd}" CommandParameter="{Binding ElementName=PanelMain}" Width="180" Content="{ex:Lang Key={x:Static langs:LangKeys.Prev}}" Style="{StaticResource ButtonPrimary}"/> |
| 56 | + <Button Command="{Binding NextCmd}" CommandParameter="{Binding ElementName=PanelMain}" Width="180" Margin="0,16,0,0" Content="{ex:Lang Key={x:Static langs:LangKeys.Next}}" Style="{StaticResource ButtonPrimary}"/> |
| 57 | + </StackPanel> |
| 58 | + <hc:StepBar Margin="0,0,0,32" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Dock="Bottom"> |
| 59 | + <hc:StepBarItem Content="{ex:Lang Key={x:Static langs:LangKeys.Register}}"/> |
| 60 | + <hc:StepBarItem Content="{ex:Lang Key={x:Static langs:LangKeys.BasicInfo}}"/> |
| 61 | + <hc:StepBarItem Content="{ex:Lang Key={x:Static langs:LangKeys.UploadFile}}"/> |
| 62 | + <hc:StepBarItem Content="{ex:Lang Key={x:Static langs:LangKeys.Complete}}"/> |
| 63 | + </hc:StepBar> |
| 64 | + <hc:StepBar Grid.Column="0" Grid.Row="3" ItemsSource="{Binding DataList}" Dock="Left"> |
| 65 | + <hc:StepBar.ItemTemplate> |
| 66 | + <DataTemplate> |
| 67 | + <StackPanel> |
| 68 | + <TextBlock FontSize="16" FontWeight="Bold" HorizontalAlignment="Left"> |
| 69 | + <Run Text="{ex:Lang Key={Binding Header}}"/> |
| 70 | + <Run Text="{Binding Index,RelativeSource={RelativeSource AncestorType=hc:StepBarItem}}"/> |
| 71 | + </TextBlock> |
| 72 | + <TextBlock Margin="0,4,0,0" Text="{ex:Lang Key={Binding Content}}"/> |
| 73 | + </StackPanel> |
| 74 | + </DataTemplate> |
| 75 | + </hc:StepBar.ItemTemplate> |
| 76 | + </hc:StepBar> |
| 77 | + <hc:StepBar Grid.Column="1" Grid.Row="3" ItemsSource="{Binding DataList}" Dock="Right"> |
| 78 | + <hc:StepBar.ItemTemplate> |
| 79 | + <DataTemplate> |
| 80 | + <StackPanel> |
| 81 | + <TextBlock FontSize="16" FontWeight="Bold" HorizontalAlignment="Left"> |
| 82 | + <Run Text="{ex:Lang Key={Binding Header}}"/> |
| 83 | + <Run Text="{Binding Index,RelativeSource={RelativeSource AncestorType=hc:StepBarItem}}"/> |
| 84 | + </TextBlock> |
| 85 | + <TextBlock Margin="0,4,0,0" Text="{ex:Lang Key={Binding Content}}"/> |
| 86 | + </StackPanel> |
| 87 | + </DataTemplate> |
| 88 | + </hc:StepBar.ItemTemplate> |
| 89 | + </hc:StepBar> |
| 90 | +</Grid> |
| 91 | +``` |
| 92 | + |
| 93 | + |
0 commit comments