为了账号安全,请及时绑定邮箱和手机立即绑定

我的嵌套绑定没有刷新我的主页

我的嵌套绑定没有刷新我的主页

C#
一只斗牛犬 2022-12-04 13:15:45
我正在做一个 UWP 应用程序。我不知道 UWP 或 XAML,所以我正在学习。我有我的课程 _Viewmodel.cs:namespace IHM_UWP{public class _ViewModel : INotifyPropertyChanged{    private GestionBras bras= new GestionBras(); //On peut ajouter cet instance dans la classe App.Xaml.cs?    public event PropertyChangedEventHandler PropertyChanged;    public void NotifyPropertyChanged([CallerMemberName] string str = "")    {        if (PropertyChanged != null)        {            PropertyChanged(this, new PropertyChangedEventArgs(str));        }    }    /// <summary>    /// Commande pour lancer la connexion au bras    /// </summary>    private ICommand connect;    public ICommand Connect    {        get        {            if (this.connect == null)                this.connect = new RelayCommand(() => this.Bras.ConnectAsync());            return this.connect;        }    }    public GestionBras Bras { get => bras; set => bras = value; }}}当我点击我的“连接”按钮时,我启动了一种连接到树莓板的方法,如果连接正常,我想将我的按钮上的内容更改为“断开手臂”,我在按钮上使用绑定数据:Content= “{Binding Bras.Com.CanConnect, Mode=TwoWay}”,当我启动应用程序时,我看到变量 CanConnect 在我的代码中各处都正确更改,我的问题是我的应用程序窗口没有更改此值:/有人可以解释我为什么这不起作用:)预先感谢您的回答,对不起我的英语水平^^
查看完整描述

1 回答

?
白衣非少年

TA贡献1155条经验 获得超0个赞

您的DisableButton()方法应该设置属性C anConnect 而不是字段c anConnect 以便OnPropertyChanged调用方法和PropertyChanged引发事件:


public void DisableButton()

{

    CanConnect = disconnectMsg;

}


查看完整回答
反对 回复 2022-12-04
  • 1 回答
  • 0 关注
  • 47 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信