初めに
https://qiita.com/sun_bacon/items/6f74ef44c35c508791d1
こちらの記事に大変助けられました、圧倒的感謝。
こちらを参考に、実装していく中で実際にBindingしている値が変わった時を
検知するのをメモ代わりに記事にします。
検知するとこ
CustomViewCell.cs
public class CustomViewCell: ViewCell
{
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
if(this.BindingContext != null && this.BindingContext is INotifyPropertyChanged)
{
(this.BindingContext as INotifyPropertyChanged).PropertyChanged += CustomPropertyChanged;
}
}
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
base.OnPropertyChanged(propertyName);
if(propertyName == "RealCell")
{
((DynamicListView)this.Parent).OnDataChanged(false);
}
}
private void CustomPropertyChanged(object sender, PropertyChangedEventArgs e)
{
((DynamicListView)this.Parent).OnDataChanged(true);
}
}
ListViewは「初めに」に記載している記事をご覧ください。
trueとfalseについては、表示後に子ViewをViewCell内に表示する際
どうしてもDelayを数ミリ秒設定しないとうまく反映されないので
表示後にProperty変わった時、DelayかけるためにFLGをつけてます。
最後に
なんで、Bindingしたら可変にならなくなるのか・・・。