【问题标题】:Xamarin.Forms - Triggering an IsBusy BindingXamarin.Forms - 触发 IsBusy 绑定
【发布时间】: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


    【解决方案1】:

    您有多种选择来欺骗您的 IsBusy 指标:

    • 通过命令
    • 通过绑定
    • 如果您的属性不是 bool 类型,则通过绑定和转换器。

    但是你需要设置 IsBusy 而不是 isBusy。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-05
      • 1970-01-01
      • 2021-10-09
      • 2018-09-23
      • 1970-01-01
      • 1970-01-01
      • 2015-09-24
      • 1970-01-01
      相关资源
      最近更新 更多