Getting Started With C1ProgressIndicator

C1ProgressIndicator is one of the new controls added in the latest Studio for WPF 2014 V3 release. This control can display the progress while a process is being executed. One example is while loading data or other documents in a datacentric application. C1ProgressIndicator is very useful in a multi-threaded environment where multiple threads are executing at the same time and for putting a thread into wait state or sleep state. In this tutorial, you will learn how to use C1ProgessIndicator.

How to add C1ProgressIndicator

Here are the steps to add C1ProgressIndicator into your project:-

  1. You can drag and drop C1ProgressIndicator directly from the toolbox into your XAML designer. Or C1ProgressIndicator comes under C1.WPF.4 dll, so you need to add this dll into your project references in order to add C1ProgressIndicator into your project either through XAML markup or using code.
  2. After adding C1ProgressIndicator, you need to know how to activate or deactivate this control to show the progress. For this, you need to remember an important property i.e. IsActive which can be set to true or false in order to activate or deactivate the control.

How to use C1ProgressIndicator

Now, lets take up an example to demonstrate how to use C1ProgressIndicator :- Step1. First of all, you need a container control to show C1ProgressIndicator so here we have used a C1Window control to display the C1ProgressIndicator. Step2. C1ProgressIndicator can display any custom text, here we are showing the progress percentage while the data is loading. Step3. Now, this C1Window control is displayed until the data from C1DataGrid or C1Chart is completely loaded. Therefore, we have used the Threading concept for inter-dependent processing of Data Loading and the C1ProgressIndicator. Step4. C1Window gets automatically closed as soon as the data gets loaded into the C1DataGrid or C1Chart. Here is the code snippet for the same:-

public void ShowProgressIndicator(String msg)  
    var w = new C1Window();  
    StackPanel MyStackPanel = new StackPanel();  
    TextBlock MyPercentProgress = new TextBlock();  
    C1ProgressIndicator pi = new C1ProgressIndicator();  
    pi.Header = msg;  
    pi.Foreground = new SolidColorBrush(Colors.Green);  
    w.Content = MyStackPanel;  
    w.Width = 300;  
    w.Height = 150;  
    Thread t1 = new Thread(new ThreadStart(() =>  
        for (int i = 1; i <= 100; i++)         {             this.Dispatcher.BeginInvoke(new Action(() =>  
                int counter = i;  
                string myString = counter.ToString();  
                MyPercentProgress.Text = myString + "% Data Loaded";  
                pi.IsActive = true;  
                if (counter == 100)  
                    this.c1Chart.Visibility = Visibility.Visible;  
                    this.c1DataGrid.Visibility = Visibility.Visible;  
    pi.IsActive = false;  

See it in action!! C1ProgressIndicator Download Sample


GrapeCity Developer Tools
comments powered by Disqus