を助けることができ、あなたのカスタムキューINotifyCollectionChangedインターフェイスを実装(ObservableQueue)を書くことができますINotifyCollectionChanged
を実装しましたか?コレクションにアイテムを追加する、またはコレクションからアイテムを削除するなどのアクションの通知に必要です。ここ
は、キューのためのシンプルな実装です:
public class ObservableQueue<T> : INotifyCollectionChanged, IEnumerable<T>
{
public event NotifyCollectionChangedEventHandler CollectionChanged;
private readonly Queue<T> queue = new Queue<T>();
public void Enqueue(T item)
{
queue.Enqueue(item);
if (CollectionChanged != null)
CollectionChanged(this,
new NotifyCollectionChangedEventArgs(
NotifyCollectionChangedAction.Add, item));
}
public T Dequeue()
{
var item = queue.Dequeue();
if (CollectionChanged != null)
CollectionChanged(this,
new NotifyCollectionChangedEventArgs(
NotifyCollectionChangedAction.Remove, item));
return item;
}
public IEnumerator<T> GetEnumerator()
{
return queue.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
あなたがキューにリストボックスをバインドする方法を教えてください。 IListまたはIListSourceにバインドする必要があるというエラーが表示される – vkapadia