This is a migrated thread and some comments may be shown as answers.

basic question

3 Answers 131 Views
BusyIndicator
This is a migrated thread and some comments may be shown as answers.
ronald
Top achievements
Rank 1
ronald asked on 09 Feb 2011, 06:05 AM
What is wrong with thsi code? why the busy indicator does not show up?


<Window xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  x:Class="WpfApplication1.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid HorizontalAlignment="Stretch">
 
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
 
        <telerik:RadButton Click="Button_Click" Grid.Row="0" HorizontalAlignment="Center" Content="Load Appointments" FontWeight="Bold" Margin="12" Padding="18 4" />
        <telerik:RadBusyIndicator x:Name="busyIndicator" Grid.Row="1" BusyContent="Loading data....">
            <Button Height="34" Width="90" Content="xxx"/>
        </telerik:RadBusyIndicator>
 
    </Grid>
</Window>



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
 
namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
 
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            busyIndicator.IsBusy = true;
 
            System.Threading.Thread.Sleep(100000);
 
            busyIndicator.IsBusy = false;
 
        }
    }
}

3 Answers, 1 is accepted

Sort by
0
Teodor
Telerik team
answered on 10 Feb 2011, 11:24 AM
Hi Ronald,

Thank you for contacting us.

In the Button_Click event handler you are sleeping the thread (System.Threading.Thread.Sleep(100000)), which causes the UI to become inresponsive and thus prevents the RadBusyIndicator to show its busy indication. 

You can change the method like:

private void Button_Click(object sender, RoutedEventArgs e)
        {
            busyIndicator.IsBusy = !busyIndicator.IsBusy;
        }

In this way you will be able to toggle the IsBusy property between true and false. 
 
Hope this helps. Let us know in case you have further help.

Best wishes,
Teodor
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
ronald
Top achievements
Rank 1
answered on 11 Feb 2011, 07:51 AM
then i need to implement muthithread/asynchronous method call to use the busy indicator?!
0
Teodor
Telerik team
answered on 11 Feb 2011, 10:27 AM
Hi Ronald,

Executing long-running operations in the background is the best approach because thus they do not block the UI thread. See this demo to see this implemented using a BackgroundWorker.

Hope this helps.

Kind regards,
Teodor
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
BusyIndicator
Asked by
ronald
Top achievements
Rank 1
Answers by
Teodor
Telerik team
ronald
Top achievements
Rank 1
Share this question
or