I am currently having 2 issues with the RadGridView
1)
I am receiving calls from a WCF Service in the client that do the usual CRUD actions. Of course this comes in on a different thread than the UI thread. So I have a dispatchable observable collection with the code below.
The problem is the object subscribed to NotifyCollectionChanged event for the grid is WeakEvent.WeakListener and the cast to DispatcherObject fails (null). How do I get the DispatcherObject from handler.Target. I'm trying to make this work so that I don't have to use Application.Current.Dispatcher as a bail out so that it will work for UI objects not on the primary UI thread. Is there a work around?
2)
I have detected some odd behavior for add new item. If I have a grid and remove all items and then want to add more back into the grid it works fine. However, if I remove all items from the collection and then close the application and restart when I click the add new item header nothing happens. i.e., a new row is not added. The collection I am using is the one above and the collection is there (Not null), it is just empty. Thoughts?
Thanks for the help,
Rick
1)
I am receiving calls from a WCF Service in the client that do the usual CRUD actions. Of course this comes in on a different thread than the UI thread. So I have a dispatchable observable collection with the code below.
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Windows.Threading; public class DispatchableObservableCollection<T> : ObservableCollection<T> { public DispatchableObservableCollection() { } public DispatchableObservableCollection(IEnumerable<T> collection) : base(collection) { } // Override the event so this class can access it public override event NotifyCollectionChangedEventHandler CollectionChanged; protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) { // Be nice - use BlockReentrancy like MSDN said using (BlockReentrancy()) { NotifyCollectionChangedEventHandler eventHandler = CollectionChanged; if (eventHandler != null) { Delegate[] delegates = eventHandler.GetInvocationList(); // Walk thru invocation list foreach (NotifyCollectionChangedEventHandler handler in delegates) { DispatcherObject dispatcherObject = handler.Target as DispatcherObject; // If the subscriber is a DispatcherObject and different thread if (dispatcherObject != null && !dispatcherObject.CheckAccess()) { // Invoke handler in the target dispatcher's thread dispatcherObject.Dispatcher.Invoke(DispatcherPriority.DataBind, handler, this, e); } else // Execute handler as is { handler(this, e); } } } } } }
The problem is the object subscribed to NotifyCollectionChanged event for the grid is WeakEvent.WeakListener and the cast to DispatcherObject fails (null). How do I get the DispatcherObject from handler.Target. I'm trying to make this work so that I don't have to use Application.Current.Dispatcher as a bail out so that it will work for UI objects not on the primary UI thread. Is there a work around?
2)
I have detected some odd behavior for add new item. If I have a grid and remove all items and then want to add more back into the grid it works fine. However, if I remove all items from the collection and then close the application and restart when I click the add new item header nothing happens. i.e., a new row is not added. The collection I am using is the one above and the collection is there (Not null), it is just empty. Thoughts?
Thanks for the help,
Rick