【发布时间】:2022-01-04 01:23:50
【问题描述】:
在 Xamarin 应用程序中,我尝试将 textcolor 与消息模型中的属性绑定。
public class Message : INotifyPropertyChanged
{
public string text { get; set; }
public Color color { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
}
任务是,当我单击集合视图中的标签时,文本应变为灰色。
我可以更改 ObservableCollection 中的颜色: this.messages = new ObservableCollection(); (这是可行的,如果我删除 ObservableCollection 中的条目,屏幕会更新)
但是当我在消息模型中更改颜色时,屏幕没有更新。
我使用 MVVMhelpers,如果可能的话,我想用它来解决问题。
最好的问候..
【问题讨论】:
-
setforcolor不会调用PropertyChanged,因此 UI 不会收到属性已更新的通知