Show loading progress when a window was loaded

3 posts, 0 answers
  1. Grigory
    Grigory avatar
    10 posts
    Member since:
    Feb 2015

    Posted 15 Aug Link to this post

    Hello,

    I'm using RadWindow to show dialog with information. After the dialog opening my software loads data from database, while the process is in progress I would like to show a user all the dialogs, all controls and BusyIndicator. However, I didn't find a correct event to handle. The way I found which should works is to use Activated event, but it didn't helped me. Data loads firstly, and then dialog appears for a user.
    The code I use:

    View:

    <telerik:RadWindow
    ...
    ...
    >
        <telerik:EventToCommandBehavior.EventBindings>
             <telerik:EventBinding Command="{Binding OnActivatedCommand}" EventName="Activated" />
        </telerik:EventToCommandBehavior.EventBindings>
        <telerik:RadBusyIndicator
                BusyContent="Loading..."
                IsBusy="{Binding IsBusy}"
                IsIndeterminate="True">
        ...
        <telerik:RadWindow/>

     

    ViewModel

    public class ViewModel: ReactiveObject
    {
        public ViewModel()
        {
            OnActivatedCommand = ReactiveCommand.Create(() =>
            {
                IsBusy = true;
                Thread.Sleep(5000); //Loading data simulation
                IsBusy = false;
            });
        }
     
        private bool _isBusy;
     
        public bool IsBusy
        {
            get { return _isBusy; }
            set { this.RaiseAndSetIfChanged(ref _isBusy, value); }
        }
     
        public ReactiveCommand OnActivatedCommand { get; private set; }
    }
  2. Grigory
    Grigory avatar
    10 posts
    Member since:
    Feb 2015

    Posted 15 Aug Link to this post

    Sorry, I mentioned in the example incorrect event. There is should be Loaded in the post. But the issue is still actual with this event.
  3. Martin Vatev
    Admin
    Martin Vatev avatar
    129 posts

    Posted 18 Aug Link to this post

    Hello Grigory,

    When you are using Thread.Sleep the UI Thread is blocked and the BusyIndicator can not be displayed. We recommend doing such operation in a separate thread using BackgroundWorker. You can take a look at this online demo.

    Regards,
    Martin Vatev
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top