observablecollection

How to inherit from ObservableCollection in Managed C++

When I try to create a class in managed C++ that inherits from ObservableCollection I get the error: error C2039: 'ObservableCollection' : is not a member of 'System::Collections::ObjectModel' Here's my code: using namespace System; using namespace System::Collections; using namespace System::Collections::Generic; using namespace Sys...

Keyed ObservableCollection in Silverlight

Hi everybody, I want to implement a keyed observable collection in Silverlight, that will store unique objects based on a property called Name. One way of doing it is to use the ObservableCollectionEx (samples in another stackoverflow post) class which subscribes to all PropertyChanged events on the contained elemens and check to see if...

Is there a List<T> in .NET 2 that raises events when the list changes?

I have used ObservableCollection<T> in the past, but that seems to belong to WPF and therefore .NET 3. And if there isn't what would be the appropriate interface for that? INotifyPropertyChanged seems not to be a very good fit for collections, while INotifyCollectionChanged is again only supported in .NET 3 and higher. ...

Observable collection without INotifyProperChanged for one way binding

For Silverlight or WPF when control is bound to Observable collection , and I am only interested in collection additions/deletions to be reflected in a control - i.e. one way binding - am I right in thinking that there is no need for INotifyPropertyChanged in a class the collection is comprised of. But changes to the existing element of ...

Missing ObservableCollection(of T)

I'm doing an experiment on WPF and MVVM, and while coding the ViewModel on Vb.net I noticed this red wavy lines under my ObservableCollection(of T)s T_T Anyway, the application is in WPF & VB.Net, under the .Net Framework 3.5 (I checked) and I have an 'Imports System.Collections.ObjectModel' on top of my class. Intellisense shows the ot...

Serializing an ObservableCollection(of T) in VB.Net

I'm trying out MVVM in VB.Net for a while now and started out with some of my entities using List(of T)s, which I xml serialized to disk. Now, I updated the classes used by the Lists to implement INotifyPropertyChanged so I also changed the List(of T)s to ObservableCollection(of T)s. After which, the XML serializer stopped working :'( A...

Why can't I set object derived from ObservableCollection<Proddata> equal to object returned as ObservableCollection<Proddata>?

I get a compile error, "Cannot implicitly conver type 'System.Collections.ObjectModel.ObservableCollection to ProddataRecsObservable'. An explicit conversion exists" See comments in following code segments. //I created a custom class called ProddataRecsObservable derived from //ObservableCollection<Proddata> so I can do some special CRU...

Best way to keep ObservableCollection and ObjectContext in sync?

Hi, I have window with a listbox bound to an ObservableCollection of People (a set of entity framework objects that I retrieve in response to a users query: a search box), i then have functions such as Edit, Delete and Add New. At the moment i am simply making sure that each time i Add or Remove something from the Database that i also ...

Problems using ListBox and observable collection as a debug log

I have a listbox bound to a view model observable collection: This works fine, minus one little hitch... assuming that the observable collection contains strings, the whole thing breaks down when entries with identical values get added to the collection, what is the best way to handle this? Custom struct instead of strings and then a ...

Optimal LINQ query to get a random sub collection - Shuffle

Please suggest an easiest way to get a random shuffled collection of count 'n' from a collection having 'N' items. where n <= N ...

ArgumentOutOfRangeException when replacing items in an ObservableCollection<T>

I'm working on a Refresh() extension method for ObservableCollection which adds, removes or replaces items based on a matching key (this means when bound to a DataGrid the grid doesn't re-scroll and items don't change their position unless they were removed). Problem is when I replace items in the ObservableCollection the last item thro...

ObservableCollection -> Listbox

I know this has been asked different ways several times, but I'm just not getting it. Why don't I see my test strings in the listbox? .cs public partial class Window1 : Window { public ObservableCollection<string> myList = new ObservableCollection<string>(); public Window1() { InitializeComponent(); myL...

wpf datagrid observablecollection

Im working on a large database application using WPF. So far, I was able to create a DataContext using Link to Sql class, store it in an ObservableCollection, and fed it to my DataGrid as DataContext. The main table in SQL I'm trying to read/write looks like this Work_Table WorkID[pk int] | frn_CustomerID[fk int] | frn_UserID[fk int] |...

C# - How do I change the value of a property based on changes to another property (ObservableCollection)?

How do I change the value of TotalPublicationsRead, when the Read property of a Publication has changed? public class Report { public ObservableCollection<Publication> Publications { get; set; } public int TotalPublicationsRead { get; set; } } public class Publication : INotifyPropertyChanged { private bool read; public boo...

How can I make a read-only ObservableCollection property?

I'd like to expose a property on a view model that contains a list of objects (from database). I need this collection to be read-only. That is, I want to prevent Add/Remove, etc. But allow the foreach and indexers to work. My intent is to declare a private field holding the editable collection and reference it with a read-only Public...

ObservableCollection turns into an Array after transported using WCF

I got a class called "Board" and one of its property's is an ObservableCollection. When i send the ObservableCollection through WCF (from server to client) end call it from my proxy, it's turned into an Array, which is no good for me. Can i keep the ObservableCollection after being sent, or do i have to kick the Array till it becomes an...

Opinion wanted: Intercepting changes to lists/collections

Although BindingList<T> and ObservableCollection<T> provide mechanisms to detect list changes, they don't support mechanisms to detect/intercept changes before they happen. I'm writing a couple of interfaces to support this, but I want to canvas your opinion. Option 1: Lists raise events for each type of action Here, consumers might w...

ObservableCollection<T> in Winforms and possible alternatives

Hey there! Winforms .net 3.5 app. In my app I have a generic class that looks like so: public class FilterItem { public FilterItem() { } public string FilterProperty { get; set; } public bool FilterPropertyChecked { get; set; } public ComparitiveOperator FilterOperator { get; set; } public string FilterValue { get; set; } } ...

PagedCollectionView when wrapping an ObservableCollection in a DataGrid clears Column headers when no data is present

I am using the PagedCollectionView for grouping. I have a DataGrid and a textbox with a search button. The ItemSource of the grid is my PagedCollectionView, and the PagedCollectionView wraps an ObservableCollection because items in the grid can have their bound objects updated by a background process. When you click search, I first clea...

Using HashSets with ObservableCollection with WPF

Hello, I'm using a ListBox to maintain a list of items in a WPF application. The ListBox data source is a HashSet wrapped in an ObservableCollection. ie, I have the following code : this.shackSet = new ObservableCollection<Shack>(new HashSet<Shack>()); this.shackListing.ItemsSource = this.shackSet; ... where shackListing is a ListB...