小编Pan*_*oul的帖子

项目更改时通知ObservableCollection

我在这个链接上找到了

ObservableCollection没有注意到它中的Item何时发生变化(即使使用INotifyPropertyChanged)

一些通知Observablecollection项目已更改的技术.这个链接中的TrulyObservableCollection似乎正是我正在寻找的.

public class TrulyObservableCollection<T> : ObservableCollection<T>
where T : INotifyPropertyChanged
{
    public TrulyObservableCollection()
    : base()
    {
        CollectionChanged += new NotifyCollectionChangedEventHandler(TrulyObservableCollection_CollectionChanged);
    }

    void TrulyObservableCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        if (e.NewItems != null)
        {
            foreach (Object item in e.NewItems)
            {
                (item as INotifyPropertyChanged).PropertyChanged += new PropertyChangedEventHandler(item_PropertyChanged);
            }
        }
        if (e.OldItems != null)
        {
            foreach (Object item in e.OldItems)
            {
                (item as INotifyPropertyChanged).PropertyChanged -= new PropertyChangedEventHandler(item_PropertyChanged);
            }
        }
    }

    void item_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        NotifyCollectionChangedEventArgs a = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);
        OnCollectionChanged(a); …
Run Code Online (Sandbox Code Playgroud)

c# collections wpf observablecollection inotifypropertychanged

39
推荐指数
3
解决办法
12万
查看次数

"uint8_t"类型的参数与"uint8_t*"类型的参数不兼容

我正在尝试在Keil上为STM32F4-Discovery 编译USB HID示例代码.此代码允许我向称为"USB HID Demonstrator"的软件发送和接收消息.

但是我的USBD_HID_DataOut功能有问题.这条线:

USB_OTG_ReadPacket((USB_OTG_CORE_HANDLE*)pdev, *Buffer, HID_OUT_PACKET);

给我一个错误:

错误#167:类型"uint8_t"的参数与"uint8_t*"类型的参数不兼容

当我压缩*Buffer,代码编译但似乎不起作用(收到的缓冲区值与预期的不匹配,但我可能会误解)并且实际上第二个参数USB_OTG_ReadPacket必须是指针所以我不要不明白为什么会出现这种错误.

Buffer变量被定义为如下:uint8_t Buffer[6];

那么编译器有问题吗?我是否必须处理将此项目代码复制到Keil的特殊问题,因为它最初是为Atollic创建的?

或者链接中是否存在错误?

c embedded pointers keil

2
推荐指数
1
解决办法
5744
查看次数