Skip to content

Commit 8036cae

Browse files
committed
Add ShowStepIndex Option for StepBar #23
1 parent 596bea7 commit 8036cae

6 files changed

Lines changed: 41 additions & 5 deletions

File tree

dev/DevWinUI.Controls/Controls/StepBar/StepBar.Property.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,22 @@ private static void OnHeaderDisplayModeChanged(DependencyObject d, DependencyPro
8585
ctl.UpdateHeaderDisplayMode();
8686
}
8787
}
88+
89+
public bool ShowStepIndex
90+
{
91+
get { return (bool)GetValue(ShowStepIndexProperty); }
92+
set { SetValue(ShowStepIndexProperty, value); }
93+
}
94+
95+
public static readonly DependencyProperty ShowStepIndexProperty =
96+
DependencyProperty.Register(nameof(ShowStepIndex), typeof(bool), typeof(StepBar), new PropertyMetadata(true, OnShowStepIndexChanged));
97+
98+
private static void OnShowStepIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
99+
{
100+
var ctl = (StepBar)d;
101+
if (ctl != null)
102+
{
103+
ctl.UpdateItems();
104+
}
105+
}
88106
}

dev/DevWinUI.Controls/Controls/StepBar/StepBar.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ private void UpdateItems()
194194
stepBarItem.Orientation = this.Orientation;
195195
stepBarItem.HeaderDisplayMode = this.HeaderDisplayMode;
196196
stepBarItem.ItemTemplate = ItemTemplate;
197+
stepBarItem.ShowStepIndex = ShowStepIndex;
197198
}
198199
}
199200

dev/DevWinUI.Controls/Controls/StepBar/StepBarItem.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ public partial class StepBarItem : ContentControl
77
private ContentPresenter contentPresenter;
88
private Border border;
99
private StackPanel panel;
10+
internal bool ShowStepIndex
11+
{
12+
get { return (bool)GetValue(ShowStepIndexProperty); }
13+
set { SetValue(ShowStepIndexProperty, value); }
14+
}
15+
16+
internal static readonly DependencyProperty ShowStepIndexProperty =
17+
DependencyProperty.Register(nameof(ShowStepIndex), typeof(bool), typeof(StepBarItem), new PropertyMetadata(true));
18+
1019
internal DataTemplate ItemTemplate
1120
{
1221
get { return (DataTemplate)GetValue(ItemTemplateProperty); }

dev/DevWinUI.Controls/Themes/Generic.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5825,7 +5825,7 @@ Themes\Styles\Win2D\Watermark.xaml
58255825
</VisualStateGroup>
58265826
</VisualStateManager.VisualStateGroups>
58275827
<Border x:Name="PART_Border" Height="40" MinWidth="40" HorizontalAlignment="Center" Background="{ThemeResource ControlSolidFillColorDefaultBrush}" BorderBrush="{ThemeResource StepBarItemInActiveBorderBrush}" BorderThickness="2" CornerRadius="90">
5828-
<TextBlock x:Name="PART_Number" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{ThemeResource TextFillColorPrimaryBrush}" Style="{StaticResource BaseTextBlockStyle}" Text="{Binding Index, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
5828+
<TextBlock x:Name="PART_Number" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{ThemeResource TextFillColorPrimaryBrush}" Style="{StaticResource BaseTextBlockStyle}" Text="{Binding Index, RelativeSource={RelativeSource Mode=TemplatedParent}}" Visibility="{Binding ShowStepIndex, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource BoolToVisibilityConverter}}" />
58295829
</Border>
58305830
<ContentPresenter x:Name="PART_Content" Margin="0,5,0,0" HorizontalAlignment="Center" ContentTemplate="{Binding ItemTemplate, RelativeSource={RelativeSource Mode=TemplatedParent}}" Foreground="{ThemeResource TextFillColorPrimaryBrush}" />
58315831
</StackPanel>
@@ -5913,7 +5913,7 @@ Themes\Styles\Win2D\Watermark.xaml
59135913
</VisualStateGroup>
59145914
</VisualStateManager.VisualStateGroups>
59155915
<Border x:Name="PART_Border" Height="40" MinWidth="40" Background="{ThemeResource ControlSolidFillColorDefaultBrush}" BorderBrush="{ThemeResource StepBarItemInActiveBorderBrush}" BorderThickness="2" CornerRadius="90">
5916-
<TextBlock x:Name="PART_Number" HorizontalAlignment="Center" VerticalAlignment="Center" FlowDirection="LeftToRight" Foreground="{ThemeResource TextFillColorPrimaryBrush}" Style="{StaticResource BaseTextBlockStyle}" Text="{Binding Index, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
5916+
<TextBlock x:Name="PART_Number" HorizontalAlignment="Center" VerticalAlignment="Center" FlowDirection="LeftToRight" Foreground="{ThemeResource TextFillColorPrimaryBrush}" Style="{StaticResource BaseTextBlockStyle}" Text="{Binding Index, RelativeSource={RelativeSource Mode=TemplatedParent}}" Visibility="{Binding ShowStepIndex, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource BoolToVisibilityConverter}}" />
59175917
</Border>
59185918
<ContentPresenter x:Name="PART_Content" Margin="5,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" ContentTemplate="{Binding ItemTemplate, RelativeSource={RelativeSource Mode=TemplatedParent}}" Foreground="{ThemeResource TextFillColorPrimaryBrush}" />
59195919
</StackPanel>
@@ -7036,6 +7036,7 @@ Themes\Styles\Win2D\Watermark.xaml
70367036
<Setter Property="ItemContainerStyle" Value="{StaticResource StepBarItemHorizontalStyle}" />
70377037
<Setter Property="Template" Value="{StaticResource StepBarHorizontalControlTemplate}" />
70387038
<Setter Property="ItemsPanel" Value="{StaticResource StepBarHorizontalItemsPanelTemplate}" />
7039+
<Setter Property="ShowStepIndex" Value="True" />
70397040
</Style>
70407041
<Style BasedOn="{StaticResource DefaultDevWinUITextBoxStyle}" TargetType="local:TextBox" />
70417042
<Style BasedOn="{StaticResource DefaultWaveProgressBarStyle}" TargetType="local:WaveProgressBar" />

dev/DevWinUI.Controls/Themes/Styles/Controls/StepBar.xaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<Setter Property="ItemContainerStyle" Value="{StaticResource StepBarItemHorizontalStyle}" />
4242
<Setter Property="Template" Value="{StaticResource StepBarHorizontalControlTemplate}" />
4343
<Setter Property="ItemsPanel" Value="{StaticResource StepBarHorizontalItemsPanelTemplate}" />
44+
<Setter Property="ShowStepIndex" Value="True" />
4445
</Style>
4546

4647
<ControlTemplate x:Key="StepBarHorizontalControlTemplate"
@@ -324,7 +325,8 @@
324325
VerticalAlignment="Center"
325326
Foreground="{ThemeResource TextFillColorPrimaryBrush}"
326327
Style="{StaticResource BaseTextBlockStyle}"
327-
Text="{Binding Index, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
328+
Text="{Binding Index, RelativeSource={RelativeSource Mode=TemplatedParent}}"
329+
Visibility="{Binding ShowStepIndex, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource BoolToVisibilityConverter}}" />
328330
</Border>
329331
<ContentPresenter x:Name="PART_Content"
330332
Margin="0,5,0,0"
@@ -460,7 +462,8 @@
460462
FlowDirection="LeftToRight"
461463
Foreground="{ThemeResource TextFillColorPrimaryBrush}"
462464
Style="{StaticResource BaseTextBlockStyle}"
463-
Text="{Binding Index, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
465+
Text="{Binding Index, RelativeSource={RelativeSource Mode=TemplatedParent}}"
466+
Visibility="{Binding ShowStepIndex, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource BoolToVisibilityConverter}}" />
464467
</Border>
465468
<ContentPresenter x:Name="PART_Content"
466469
Margin="5,0,0,0"

dev/DevWinUI.Gallery/Views/Pages/Features/StepBarPage.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@
5757
<ComboBoxItem Content="Bottom"
5858
Tag="Bottom" />
5959
</ComboBox>
60+
<ToggleSwitch x:Name="TGShowStepIndex"
61+
Header="Show StepIndex"
62+
IsOn="True" />
6063
</StackPanel>
6164
</local:ControlExample.Pane>
62-
<dev:StepBar x:Name="StepBarSample">
65+
<dev:StepBar x:Name="StepBarSample"
66+
ShowStepIndex="{x:Bind TGShowStepIndex.IsOn, Mode=OneWay}">
6367
<dev:StepBarItem Content="Register" />
6468
<dev:StepBarItem Content="BasicInfo" />
6569
<dev:StepBarItem Content="UploadFile" />

0 commit comments

Comments
 (0)