【发布时间】:2018-05-19 16:56:01
【问题描述】:
我有一个IsBusy 绑定,可以通过说bool isBusy = true ... or false 来激活它。但是,我意识到bool 是我可以将IsBusy 设置为真/假的唯一 位置。
我可以在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);
}
}
}
【问题讨论】:
标签: c# xamarin xamarin.forms binding