basic question

4 posts, 0 answers
  1. ronald
    ronald avatar
    54 posts
    Member since:
    Jan 2011

    Posted 09 Feb 2011 Link to this post

    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;
     
            }
        }
    }
  2. Teodor
    Admin
    Teodor avatar
    501 posts

    Posted 10 Feb 2011 Link to this post

    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>>
  3. UI for WPF is Visual Studio 2017 Ready
  4. ronald
    ronald avatar
    54 posts
    Member since:
    Jan 2011

    Posted 11 Feb 2011 Link to this post

    then i need to implement muthithread/asynchronous method call to use the busy indicator?!
  5. Teodor
    Admin
    Teodor avatar
    501 posts

    Posted 11 Feb 2011 Link to this post

    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>>
Back to Top