Show BusyIndicator from WPF.ExtendedToolkit

Feb 11, 2011 at 3:38 PM
Edited Feb 11, 2011 at 4:12 PM

Hi I try show busy indicator in shell which is wpf window.

In shell view I have this:

 

 

    <Grid>
<extToolkit:BusyIndicator IsBusy="{Binding Path=ShellIsBusy, Mode=OneWay,
UpdateSourceTrigger=PropertyChanged}"
BusyContent="{Binding Path=BusyMessage,Mode=OneWay,
UpdateSourceTrigger=PropertyChanged}">
<ContentControl x:Name="ActiveItem" />

</extToolkit:BusyIndicator>
</Grid>

 

Shell model class is here:

 

    [Export(typeof(IShellViewModel))]
public class ShellViewModel : Conductor<IScreen>.Collection.OneActive,
IShellViewModel, IPartImportsSatisfiedNotification
{
[Import]
internal IJinglePlayer JinglePlayer { get; set; }

private bool _isBusy;
private string _busyMessage;

public bool ShellIsBusy
{
get { return _isBusy; }
set
{
_isBusy = value;
NotifyOfPropertyChange(()=>ShellIsBusy);
}
}

public string BussyMessage
{
get { return _busyMessage; }
set
{
_busyMessage = value;
NotifyOfPropertyChange(()=>BussyMessage);
}
}

protected override void OnInitialize()
{
Show1();
base.OnInitialize();
JinglePlayer.PlayStartUp();
}

public void Show1()
{
var vm = IoC.Get<ILogOnViewModel>();
ActivateItem(vm);
}

public void Show2(IAccount account)
{
ActiveItem.Deactivate(true);
var vm = IoC.Get<IMeViewModel>();
vm.Account = account;
ActivateItem(vm); }

public void OnImportsSatisfied()
{

}
}

 

I run app, from active view model class I call this:

 

              [Import]
internal IShellViewModel Shell { get; set; }

//...

Shell.ShellIsBusy = true;
Shell.BusyMessage = "logging";

//long task

Shell.Show2(logOnResult.ReturnValue);


 

Problem is that busy indicator is showed in the moment when is active another view.

Feb 11, 2011 at 7:29 PM
Edited Feb 11, 2011 at 7:29 PM

I'm afraid you are keeping the UI thread busy with the long running task.
In these circumstance, the label update remains queued in the Dispatcher until the UI thread gets freed again.
You have to run the long task in a background thread and restore the shell state back to not busy at the end; you may also consider using Coroutines.

Feb 11, 2011 at 9:18 PM

Thank for informartion, this I need, I solved this problem with create new view in another thread

 

Something like this:

                    Task.Factory.StartNew(() => { Shell.Show2(...); });