lingme / Message-Control-WPF

WPF实现的消息中心控件|Message control centre for .net framework wpf

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MsgTab Control WPF


WPF实现的类型消息中心的控件

View代码:

<message:MessageView  Grid.Row="0" Grid.RowSpan="1" CarMessageListSourece="{Binding CarMessageList}" NotiesMessageListSourece="{Binding NotiesMessageList}"></message:MessageView>

依赖属性说明:

CarMessageListSourece 集卡消息源

NotiesMessageListSourece 警告消息源

这两个依赖属性都是MessageItem类型,具体属性如下:

public class MessageItem: INotifyPropertyChanged {
    private string _typeName;
    /// <summary>
    /// 消息标题类型(左部分类型(例:卡车编号))
    /// </summary>
    public string TypeName {
        get { return _typeName; }
        set 
        {
            _typeName = value;
            OnPropertyChanged("TypeName");
        }
    }

    private string _typeNum;
    /// <summary>
    /// 消息标题编号(右部分类型(例:04848))
    /// </summary>
    public string TypeNum {
        get { return _typeNum; }
        set 
        {
            _typeNum = value;
            OnPropertyChanged("TypeNum");
        }
    }

    private bool _isRead = false;
    /// <summary>
    /// 消息已读
    /// </summary>
    public bool IsRead {
        get { return _isRead; }
        set 
        {
            _isRead = value;
            OnPropertyChanged("IsRead");
        }
    }

    /// <summary>
    /// 消息详情(拼接)
    /// </summary>
    public string DetailedInfo {
        get {
            string str = string.Empty;
            if (ItemList != null && ItemList.Count > 0) {
                foreach(var item in ItemList) {
                    str += item.Key.PadRight(10, ' ') + "\t\t:  " + item.Value + "\n\n";
                }
            }
            return str.TrimEnd(new char[] { '\n', '\n' });
        }
    }

    private Dictionary < string, string > _itemList;
    /// <summary>
    /// 消息详情(由于消息详情可能是多条)
    /// </summary>
    public Dictionary < string, string > ItemList {
        get { return _itemList; }
        set 
        {
            _itemList = value;
            OnPropertyChanged("ItemList");
        }
    }


    public event PropertyChangedEventHandler PropertyChanged;

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

A

A

A

A

About

WPF实现的消息中心控件|Message control centre for .net framework wpf


Languages

Language:C# 100.0%