C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » C# Syntax »

Implement a progress bar within Silverlight 2 context


Posted Date: 17 Nov 2008    Resource Type: Code Snippets    Category: C# Syntax
Author: MASNSNMember Level: Gold    
Rating: 1 out of 5Points: 10



This is the XAML implementation



Orientation="Vertical"
Background="White"
>

FontFamily="Time New Romain"
FontSize="16"
FontWeight="Bold"
>
The operation progress

Foreground="Cyan"
Background="AntiqueWhite"
BorderBrush="Blue"
Maximum="100"
Width="200"
Height="20"
Margin="15"
/>
Margin="15,15"

>






And this is the C# code behind


using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

namespace Silverlight2
{
public partial class Page : UserControl
{

ProgressBar oBar;
Storyboard oTimer;
TextBlock Result;
public Page()
{
InitializeComponent();
InitializeBehaviour();

}
public void InitializeBehaviour()
{
oBar = this.FindName("myBar") as ProgressBar;
oTimer = new Storyboard();
Result = this.FindName("myTextBloc") as TextBlock;
oTimer.Duration = new Duration(new TimeSpan(10));
oTimer.Completed+=new EventHandler(oTimer_Completed);
oTimer.Begin();

}

Random x = new Random();
public void oTimer_Completed(object sender, EventArgs e)
{
int period = x.Next(1, 5)*100;

if (oBar.Value < oBar.Maximum)
{
System.Threading.Thread.CurrentThread.Join(period);
oBar.Value += 1;
oTimer.Begin();
}
if (oBar.Value >= oBar.Maximum)
Result.Text = "Operation accomplished";


}
}
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Progress Bar Silverlight 2.0 XAML C#  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Zip and Unzip files using C#
Previous Resource: switch case
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use