zoukankan      html  css  js  c++  java
  • MVVM:ViewModel片段

    public class ViewModelBase : INotifyPropertyChanged
    {
    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void OnPropertyChanged(string propertyName)
    {
    PropertyChangedEventHandler handler
    = this.PropertyChanged;
    if (handler != null)
    {
    var e
    = new PropertyChangedEventArgs(propertyName);
    handler(
    this, e);
    }
    }
    }

    public class ViewClass : ViewModelBase
    {
    int _MyField;
    public int MyField
    {
    get { return _MyField; }
    set
    {
    if (_MyField != value)
    {
    _MyField
    = value;
    base.OnPropertyChanged("MyField");
    }
    }
    }

    ObservableCollection
    <ViewClass> _Items;
    public ObservableCollection<ViewClass> Items
    {
    get
    {
    if (_Items == null)
    {
    _Items
    = new ObservableCollection<ViewClass>();
    }
    return _Items;
    }
    }
    }
  • 相关阅读:
    sass接触
    css 文字超出部分显示省略号(原)
    vue组件
    字节流
    File类、递归
    异常
    静态导入、可变参数、Collections集合工具类、集合嵌套
    Map接口
    Set接口
    List接口
  • 原文地址:https://www.cnblogs.com/rock_chen/p/2161413.html
Copyright © 2011-2022 走看看