It seems the ObservableCollection only support add, remove, clear operation from the UI thread, It throw Not Support Exception if it is operated by a NO UI thread. I tried to override methods of ObservableCollection, unfortunatly, I met lots of problems.
Any one can provide me a ObservableCollection sample which can be operated by multi-...
It seems like Microsoft had a great idea with the ObservableCollection. They are great for binding, and are super fast on the UI.
However, requiring a context switch to the Dispatcher Thread every time you want to tweak it seems like a bit much. Does anyone know the best practices for using them? Is it simply to populate an ICollecti...
I have something here that is really catching me off guard.
I have an ObservableCollection of T that is filled with items. I also have an event handler attached to the CollectionChanged event.
When you Clear the collection it causes an CollectionChanged event with e.Action set to NotifyCollectionChangedAction.Reset. Ok, that's normal. ...
Hi,,
I have WPF ListBox which is bound to a ObservableCollection,
when the collection changes, all items update their position.
The new position is stored in the collection but the UI does not update.
So I added the following:
void scenarioItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChange...
Hello all,
I have a ListBox with way too many items in it and the UI is getting slower and slower (virtualization is on, etc). So I was thinking about displaying only the first 20 items and allow to user to navigate through the result set (i.e. ObservableCollection).
Does anybody know if a Pagination mechanism exist for the ObservableC...
I want to add a single model object that has been instantiated once in XAML, and add it to two different collections (in xaml).
The following code renders fine in Blend's Design Time, but I get the following errors at run time:
For "Post1"
Object of type 'WpfBlog.Models.Tag' cannot be converted to type 'System.Collections.ObjectModel.O...
Hi all,
I have a class that inherits from ObservableCollection(Of MyObject) and the MyObject class handles INotifyPropertyChanged as it should. When the user updates this data through bound controls the collection will change as expected.
I have a 'Save' button on the form which is meant to persist this collection to disk as XML by cal...
Hi,
I've developped some data based Winforms Application this last two years and all works fine. This application are built on layers (DataAccess, Business Logic and UI). For the Businness Logic, all my objects inherit from a base class called BaseEntity with the following definition (there are some custom objects and interfaces, combin...
Time and time again I find myself having to write thread-safe versions of BindingList and ObservableCollection because, when bound to UI, these controls cannot be changed from multiple threads. What I'm trying to understand is why this is the case - is it a design fault or is this behavior intentional?
...
I have a bunch of ObservableCollections which are populated from a database. There's agood chance that during the application lifetime these collections will grow and i need them to be updated every 30 seconds or so.
I declare the collections as resources in merged dictionaries in App.xaml. I can fetch these collections fine by using ...
I'm binding to a method using an ObjectDataProvider. The class which exposes this method contains an ObservableCollection of type T:INofifyChanged. My problem is that because the methods return value is dependent upon the value of it's ObservableCollection, i need the binding to be updated when the ObservableCollection changes in any w...
I have some UI bound to an ObservableCollection of type T where 'T' implements INotifyProperty Changed properly.
The problem is i need to completely swap out the ObservableCollection at runtime since it is popluated from a SQL call. This obviously messes the whole binding up and no change notifications fire.
How can i replace the s...
I have a class called IssuesView which implements INotifyPropertyChanged. This class holds an ObservableCollection<Issue> and exposes it as a DependencyProperty called Issues for consumption by Bindings. It is defined as below -
public class IssuesView : DependencyObject, INotifyPropertyChanged
{
public Issues Issues
{
...
I want to be able to add a range and get updated for the entire bulk.
I also want to be able to cancel the action before it's done (i.e. collection changing besides the 'changed').
Related Q
http://stackoverflow.com/questions/57020/which-net-collection-for-adding-multiple-objects-at-once-and-getting-notified
...
Hello,
I have two ObservableCollections and I need to show them in one ListView control together. For this purpose I created MergedCollection which presents these two collections as one ObservableCollection. This way I can set the ListView.ItemsSource to my merged collection and both collections are listed. Adding works fine but when I ...
I have an instance of ObservableCollection bound to a WPF listbox with two separate data templates (one for display, one for editing). The data template for editing has a one-way binding on the textbox, and a Save button.
What changes do I need to make so that when I press the Save button (after putting the list item in edit mode), the...
I have a method that receives a customer object which has changed properties and I want to save it back into the main data store by replacing the old version of that object.
Does anyone know the correct C# way to write the pseudo code to do this below?
public static void Save(Customer customer)
{
ObservableCollection<Cu...
Something strange is going on with ObservableCollection.
I have the following code:
private readonly ObservableCollection<DisplayVerse> _display;
private readonly ListBox _box;
private void TransferToDisplay()
{
double elementsHeight = 0;
_display.Clear();
for (int i = 0; i < _source.Count; i++) {
DisplayVerse verse = ...
Hi,
I have two observeable collection both set to a class of properties. I am needing to combine both of those collections into one listbox. I have looked up at the Compositecollection class but it is not what I need. Ideally, I want the listbox to look like this...
Think of this as a listbox control and each listbox item contains obj...
I'm trying to set a TwoWay binding to a combo box using only a selection of a collection's objects. Currently, everything works out ok if I just want to bind everything in the colelction, but in the example class below, what if I only want to show items where Active=True? I can filter the items using LINQ like ItemsSource = FROM x IN Col...