为类型增加选择属性

时间:2021-08-25 14:37:31
为类型增加选择属性为类型增加选择属性
using Microsoft.Practices.Prism.ViewModel;

namespace Common
{
    /// <summary>
    /// 增加选择属性
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class SelectableObject<T> : NotificationObject
    {
        public SelectableObject(T item)
        {
            Item = item;
        }

        /// <summary>
        /// 是否选中
        /// </summary>
        private bool _isSelected;
        public bool IsSelected
        {
            get
            {
                return _isSelected;
            }
            set
            {
                if (_isSelected != value)
                {
                    _isSelected = value;
                    RaisePropertyChanged("IsSelected");
                }
            }
        }

        /// <summary>
        /// 封装的对象
        /// </summary>
        public T Item { get; set; }
    }
}
View Code