Progress Ring on Timer by imam-yemina
You can also change the progress ring into progress bar. The whole process for progress bar is same.
The code of MainPage.Xaml.cs is:
public sealed partial class MainPage : Page
{
int time = 0;
DispatcherTimer dispatch;
public MainPage()
{
this.InitializeComponent();
dispatch = new DispatcherTimer();
if(!dispatch.IsEnabled)
{
dispatch.Tick += dispatch_Tick; //press double here!
dispatch.Interval = new TimeSpan(0, 0, 1);
dispatch.Start();
}
}
void dispatch_Tick(object sender, object e)
{
//throw new NotImplementedException();
time++;
if(time>9)
{
ProgRing.IsActive = false;
dispatch.Stop();
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ProgRing.IsActive = true;
dispatch.Start();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
ProgRing.IsActive=false;
}
}
The code of MainPage.Xaml is:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="109*"/>
<RowDefinition Height="659*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="44*"/>
<ColumnDefinition Width="639*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" TextWrapping="Wrap" Text="Progress Ring" VerticalAlignment="Center" FontSize="48"/>
<ProgressRing x:Name="ProgRing" Grid.Column="1" HorizontalAlignment="Left" Margin="485,209,0,0" Grid.Row="1" VerticalAlignment="Top" Height="113" Width="131" Background="#FF575757" Foreground="#FFFF0C00"/>
<Button Content="Start" Grid.Column="1" HorizontalAlignment="Left" Margin="242,365,0,0" Grid.Row="1" VerticalAlignment="Top" Height="80" Width="182" FontSize="48" Click="Button_Click"/>
<Button Content="stop" Grid.Column="1" HorizontalAlignment="Left" Margin="695,365,0,0" Grid.Row="1" VerticalAlignment="Top" Height="80" Width="182" FontSize="48" Click="Button_Click_1"/>
</Grid>

Create Your Badge


0 comments:
Post a Comment