2

フレーム内のページの読み込みに時間がかかります。つまり、コントロールが最初にページに表示されるまでに時間がかかります。メインの window.cs ファイルのどこで IsBusy = true を設定する必要がありますか。ビジー インジケーターの使用方法がわかりません。いつ true または false に切り替える必要がありますか。どのように使用すればよいですか?前もって感謝します。

4

2 に答える 2

2

Xamlビジー インジケータでラップします。あなたが使用していると仮定してMVVM

  <xctk:BusyIndicator BusyContent="{Binding BusyText}" IsBusy="{Binding IsBusy}">
    <Grid>
       <!--Your controls and content here-->
    </Grid>
</xctk:BusyIndicator>

あなたのviewmodel

    /// <summary>
    /// To handle the Busy Indicator's state to busy or not
    /// </summary>
    private bool _isBusy;
    public bool IsBusy
    {
        get
        {
            return _isBusy;
        }
        set
        {
            _isBusy = value;
            RaisePropertyChanged(() => IsBusy);
        }
    }

    private string _busyText;
    //Busy Text Content
    public string BusyText
    {
        get { return _busyText; }
        set
        {
            _busyText = value;
            RaisePropertyChanged(() => BusyText);
        }
    }

コマンドとコマンド ハンドラ

    //A Command action that can bind to a button
    private RelayCommand _myCommand;
    public RelayCommand MyCommand
    {
        get
        {
            return _myCommand??
                   (_myCommand= new RelayCommand(async () => await CommandHandler(), CanExecuteBoolean));
        }
    }

internal async Task CommandHandler()
    {
       Isbusy = true;
       BusyText = "Loading Something...";
       Thread.Sleep(3000); // Do your operation over here
       Isbusy = false;
    }
于 2015-09-17T10:09:23.357 に答える