How to use Progressbar control in Silverlight

Its common in web application to upload and download files. And if the the file is large, then we should have some technique to show the progress of the file uploaded or downloaded.

In such cases, progressbar control plays an important role.
Here we will see how to create progressbar control in silverlight application.

<ProgressBar Height="24" Margin="101,87,157,0" VerticalAlignment="Top" IsIndeterminate="True"/>

The above code defines a progressbar control with isIndeterminate enabled. In this, we will not see the overall progress.

Here is another example with some styling.

<ProgressBar x:Name="pb1" Minimum="0" Maximum="100" Height="25" Margin="101,166,157,0" BorderBrush="#FF121212" BorderThickness="2" VerticalAlignment="Top" Foreground="#FFEC0606" Background="#FFF5F615" IsIndeterminate="True"/>

And now the default way to create the control.

<ProgressBar x:Name="pb2" Margin="101,239,157,209" Foreground="#FFF8490A"/>

In this last form we will show the progress with the mouse wheel event.

pb2.MouseWheel += new MouseWheelEventHandler(pb2_MouseWheel);

void pb2_MouseWheel(object sender, MouseWheelEventArgs e)


          pb2.Value = pb2.Value + 1;


The result for all the three examples is as follows: