簡體   English   中英

從Caliburn.Micro中的WPF.ExtendedToolkit顯示BusyIndi​​cator

[英]Show BusyIndicator from WPF.ExtendedToolkit in Caliburn.Micro

嗨,我嘗試在shell是wpf窗口中顯示忙碌指示器。

在外殼視圖中,我有這個:

<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模型類在這里:

[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()
    {

    }
}

我從活動視圖模型類運行應用程序,我稱其為:

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

            //...

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

            //long task

            Shell.Show2(logOnResult.ReturnValue);

問題是在激活另一個視圖時會顯示忙碌指示器。

我發布我的解決方案,也許有人會有更好的主意。 問題是長時間運行的任務使UI線程忙,所以我在另一個線程的活動新視圖上調用此任務和shell方法。

像這樣:

Task.Factory.StartNew(() => { //long task });

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

可以顯示此解鎖UI線程和BusyIndi​​cator。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM