I am working on WPF and I am using a ListView, and I need to fire an event when an item is added to it. I have tried this:
var dependencyPropertyDescriptor = DependencyPropertyDescriptor.FromProperty(ItemsControl.ItemsSourceProperty, typeof(ListView));
if (dependencyPropertyDescriptor != null)
{
dependencyPropertyDescriptor.AddValueChanged(this, ItemsSourcePropertyChangedCallback);
}
.....
private void ItemsSourcePropertyChangedCallback(object sender, EventArgs e)
{
RaiseItemsSourcePropertyChangedEvent();
}
But It seems to be working only when the entire collection is changed, I have read this post: event-fired-when-item-is-added-to-listview, but the best answer applies for a listBox only. I tried to change the code to ListView but I wasnt able to do that.
I hope You can help me. Thank you in advance.
BeginInvoke
does not accept the declaration as the example. It says thatDispatcherPriority
does not exist