Skip to content

Commit

Permalink
feat(progressbar): Added display of CurrentState name in sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
carldebilly committed Jun 16, 2020
1 parent 11b51ba commit 3f6f1f8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock FontSize="15" Grid.Row="0" Grid.Column="0" FontWeight="Bold">Control--&gt;</TextBlock>
<winui:ProgressBar Grid.Row="0" Grid.Column="1"
x:Name="progressBar"
MinHeight="{Binding Value, ElementName=minHeight}"
Value="{Binding Value, ElementName=slider}"
Padding="{Binding Value, ElementName=padding, Converter={StaticResource doubleToThickness}}"
Expand All @@ -52,5 +54,12 @@
<ToggleButton x:Name="showError">ShowError</ToggleButton>
<ToggleButton x:Name="showPaused">ShowPaused</ToggleButton>
</StackPanel>

<TextBlock FontSize="15" Grid.Row="5" Grid.Column="0">States:</TextBlock>

<ScrollViewer Grid.Row="5" Grid.Column="1">
<TextBlock x:Name="states" FontSize="9" FontFamily="Monospace" />
</ScrollViewer>

</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Windows.UI.Xaml.Controls;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Uno.UI.Samples.Controls;
using Uno.UI.Extensions;

namespace UITests.Microsoft_UI_Xaml_Controls.ProgressBar
{
Expand All @@ -9,6 +12,24 @@ public sealed partial class WinUIProgressBarSimple : Page
public WinUIProgressBarSimple()
{
this.InitializeComponent();

Loaded += (snd, evt) =>
{
var root = Uno.UI.Extensions.DependencyObjectExtensions.FindFirstChild<Grid>(progressBar);
var stateGroups = VisualStateManager.GetVisualStateGroups(root);
stateGroups
.First()
.CurrentStateChanging += (s, e) =>
{
states.Text += $">>{e.NewState.Name}>> ";
};
stateGroups
.First()
.CurrentStateChanged += (s, e) =>
{
states.Text += $"[{e.NewState.Name}]\n";
};
};
}
}
}

0 comments on commit 3f6f1f8

Please sign in to comment.