Silverlight: ListBox ItemsChanged event

Bits me why this is not implemented.
i was missing an event on the ListBox – ItemsChanged.
as you can see the implementation is so easy:

using System.Collections.Specialized;
...
public class ListBoxGeneric : ListBox
{
    #region Constructor
    public ListBoxGeneric() : base() { }
    #endregion  Constructor

    #region Override
    protected override void OnItemsChanged(
        NotifyCollectionChangedEventArgs e)
    {
        base.OnItemsChanged(e);
        OnItemsChangedEvent(e);
    }
    #endregion Override

    #region Class Events

    public delegate void ItemsChangedEventHandler(object sender,
        NotifyCollectionChangedEventArgs e);
    public event ItemsChangedEventHandler ItemsChanged;

    private void OnItemsChangedEvent(
        NotifyCollectionChangedEventArgs e)
    {
        if (ItemsChanged != null)
        {
            ItemsChanged(this, e);
        }
    }

    #endregion Class Events
}
Advertisements

2 Responses to Silverlight: ListBox ItemsChanged event

  1. Sam says:

    thanks buddy, just what I needed 🙂

  2. anjani says:

    Thank you! This really helped!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: