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

Show loading progress when a window was loaded

2 Answers 302 Views
Window
This is a migrated thread and some comments may be shown as answers.
Grigory
Top achievements
Rank 2
Grigory asked on 15 Aug 2017, 03:14 PM

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 Answers, 1 is accepted

Sort by
0
Grigory
Top achievements
Rank 2
answered on 15 Aug 2017, 08:22 PM
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.
0
Martin
Telerik team
answered on 18 Aug 2017, 12:28 PM
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.
Tags
Window
Asked by
Grigory
Top achievements
Rank 2
Answers by
Grigory
Top achievements
Rank 2
Martin
Telerik team
Share this question
or