C# Forms-触发IsBusy绑定
我有一个C# Forms-触发IsBusy绑定,c#,xamarin,xamarin.forms,binding,C#,Xamarin,Xamarin.forms,Binding,我有一个IsBusy绑定,可以通过说bool IsBusy=true来激活它。。。或false。然而,我意识到,bool是我唯一可以将IsBusy设置为true/false的地方 我可以在bool以外的其他地方触发我的IsBusy绑定吗?我一直在到处试用IsBusy=true/false和阅读教程,我不确定我做了什么不同,它似乎没有更新我的IsBusy绑定 using System; using System.Collections.Generic; using System.Text; usi
IsBusy
绑定,可以通过说bool IsBusy=true来激活它。。。或false
。然而,我意识到,bool
是我唯一可以将IsBusy
设置为true/false的地方
我可以在bool
以外的其他地方触发我的IsBusy
绑定吗?我一直在到处试用IsBusy=true/false
和阅读教程,我不确定我做了什么不同,它似乎没有更新我的IsBusy
绑定
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System;
using System.ComponentModel;
using System.Windows.Input;
using Xamarin.Forms;
using Rox;
namespace PreAppStructure
{
public class RoxViewModel : INotifyPropertyChanged
{
public RoxViewModel()
{
}
// IsBusy be manually toggled with: bool isBusy = true/false;
bool isBusy;
// Can I toggle it somewhere else?
public event PropertyChangedEventHandler PropertyChanged;
public bool IsBusy
{
get { return isBusy; }
set
{
isBusy = value;
OnPropertyChanged(nameof(IsBusy));
}
}
//Property Changes
protected void OnPropertyChanged(string propertyName)
{
PropertyChangedEventArgs eventArgs = new PropertyChangedEventArgs(propertyName);
PropertyChanged?.Invoke(this, eventArgs);
}
}
}
您有多个选项来欺骗您的IsBusy指示灯:
- 通过命令
- 通过装订
- 如果属性不是bool类型,则通过绑定和转换器