Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在wpf中使用忙指示器_Wpf_Wpftoolkit_Busyindicator - Fatal编程技术网

如何在wpf中使用忙指示器

如何在wpf中使用忙指示器,wpf,wpftoolkit,busyindicator,Wpf,Wpftoolkit,Busyindicator,我在一个框架内的页面需要时间加载,这意味着控件第一次出现在页面上需要一些时间。在我的main window.cs文件中,我应该在哪里设置IsBusy=true。我不知道如何使用busy指示器。我应该在何时将其切换为true或false。请指导我如何使用它?提前感谢。通常,在开始执行繁重的处理之前,您会设置忙指示灯,这取决于您的代码 通常情况下,在您生成一个后台线程来完成大量工作之前,用户界面会说它现在很忙,当线程完成时,用户界面就会“取消busy” 用忙指示器包装您的Xaml。假设您使用的是MV

我在一个框架内的页面需要时间加载,这意味着控件第一次出现在页面上需要一些时间。在我的main window.cs文件中,我应该在哪里设置IsBusy=true。我不知道如何使用busy指示器。我应该在何时将其切换为true或false。请指导我如何使用它?提前感谢。

通常,在开始执行繁重的处理之前,您会设置忙指示灯,这取决于您的代码


通常情况下,在您生成一个后台线程来完成大量工作之前,用户界面会说它现在很忙,当线程完成时,用户界面就会“取消busy”

用忙指示器包装您的
Xaml
。假设您使用的是
MVVM

  <xctk:BusyIndicator BusyContent="{Binding BusyText}" IsBusy="{Binding IsBusy}">
    <Grid>
       <!--Your controls and content here-->
    </Grid>
</xctk:BusyIndicator>
命令和命令处理程序

    //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;
    }
    //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;
    }