observablecollection

WFP DataGrid ItemsSource binding to ObservableCollection doesn't update beyond first setting?

I am binding a WPF application DataGrid to an ObservableCollection via the DataGrid's "ItemSource". Initially the DataGrid does come up with headings and values, however the upgrades made to the ObservableCollection are not reflected? (i.e. when I come back programmatically and increase the "Total" value) The ObservableCollection I a...

What is the proper way to create a dependency property bindable to an observable collection?

Hi, I need to create a dependency property on a custom control. The problem is that the propertyChangedCallback does not get called when the collection changes. How should I properly handle this scenario? I am afraid of memory leaks caused by simply event hooking to the CollectionChanged event during the initial property change (when t...

Silverlight & ObservableCollection: Raising CollectionChanged on UI thread

I need to raise the CollectionChanged event of an ObservableCollection on the UI thread. I have seen different approaches ranging from a wrapper class to custom implementation of the relevant interface. Is there any simple way to override INotifyCollectionChanged on an ObservableCollection to accomplish this? Thanks. ...

WPF ObservableCollection: How to add a blank line in one form's combobox, but not actually affect the ObservableCollection?

I have a static ObservableCollection in a Data Repository class. I use it to populate a combobox on one of my forms (which needs to be able to include a blank line which represents NULL). I use the same ObservableCollection to populate a DataGrid, so I don't want the blank item in the actual ObservableCollection. How do I actually do th...

What is the correct way to get a Collection with a Collection from a DomainService?

Currently I have a DomainService that gets lists of MainBusinessLines, Groups, and LOBs. It then loops and adds the Groups to the appropriate MainBusinessLine, and adds the LOBs to the appropriate Group. I have stepped through and confirmed that the collections are correct. But the issue is when the LoadOperation of the DomainContext loa...

Is there a Threadsafe Observable collection in .NET 4 ?

Hi, Platform: WPF, .NET 4.0, C# 4.0 Problem: In the Mainwindow.xaml i have a ListBox bound to a Customer collection which is currently an ObservableCollection< Customer >. ObservableCollection<Customer> c = new ObservableCollection<Customer>(); This collection can be updated via multiple sources, like FileSystem, WebService etc. To ...

Binding treeview to ObservableCollection with a different hierarchy configuration

Hello, I have source-ObservableCollection holding hierarchical data in configuration A, and i want to display it using a treeview in configuration B(add custom parent-nodes, display different types of data on same hierarchy level). i've managed to to it only by setting the OC (ObservableCollection) hierarchy to match the exact desired o...

Linq search result by closest match

I have an ObservableCollection, which holds a Person object. I have a search feature in my application, and would like to display the most relevant results at the top. What would be the most efficient way of doing this? My current search method simply calls the contains method: var results = (from s in userList where s.N...

Unable to get DataGrid working with ObservableCollection

Everything compiles, but at run time a blank row is displayed. If I try to edit an entry, it says "No XPath set". What am I doing wrong? I tried a ton of variations, not having the INotifyPropertyChanged interface etc. The base class is: public class Variable : INotifyPropertyChanged { public string Name; public st...

WPF Datagrid Row Editing "ENDED" event

I know that WPF datagrid has "RowEditEnding" event , but I need to fire the event on after the Row has comitted to check if the newly added row is duplicated and merge the duplicated row. My datagrid has "CanUserAddRow" property set to True. I am using EntityObservableCollection that extends ObservableCollection to synchronize my entity...

ObservableCollection<T> binding through MVVM doesn't update the view

Hello, I have the following simplified ViewModel public class UserViewModel : IUserViewModel { public DelegateCommand<object> NewUser { get; private set; } public ObservableCollection<UserInfo> UserList { get; set; } public UserViewModel( ) { NewUser = new DelegateCommand<object>( OnNewUser ); this.UserLi...

MVVM Tabs: Focus new tab

I can add & remove tabs similar to the famous MSDN article. Basically a ObservableCollection<TabViewModels>. And I add tabs like _tabs.Add(new TabViewModel()) but the newest tab is not focused. I want to focus it. How do I do it? 1 way to do it since i have a view source for my observable collection, I can do the below... another optio...

Dependency Property Not Updating?

I don't know if I am using dependency properties right, but it seems my View never updates. I have a style trigger to change the styles of my elements. It seems the code runs, but the view is not updated. This is my 1st time using a Dependency Property & I maybe using it wrong C# public bool CanSave { get { return (bool)GetValue(C...

ArrayList C# Contains method query

I have an ObservableCollection<myClass> list. It contains a 10 objects of type MyClass. class MyClass { string name; int age; } If I want to find all items in list where age = 10, can I use the Contains method? If yes how can I do this without using iteration? ...

Can you use a CollectionViewSource inside a DataTemplate?

Is it possible to explicitly use a CollectionViewSource inside a data template? Normally we'd put the CollectionViewSource in the resources alongside the template, but our model doesn't allow that because the 'source' of the collectionviewsource is a property of the DataContext at this level in the tree, meaning there needs to be an ins...

GUI frozen while i update my ObservableCollection

I have a WPF application that displays an ObservableCollection. It's about 182 rows, and the object (let's call it PositionLight) inside the collection has about 70 properties to display. All calculation to input data in these properties are made in a second thread which will recalc everything every 20 secondes, and will send a List to ...

how to use collection from one form to other

i have collection of classes in one form and i want to use the same collection in other form. so here is the place where the collection is made public partial class Window1 : Window { string text; string[] tmp; double procent; public ObservableCollection<element> elementi = new ObservableCollection<element>(); ...

ObservableCollection for Web froms

I have not worked on WPF.I had that Observable collection works like events to LINQ.I also referred some libraries in codeplex (obtics) and MS Reactive Framework all are specific for WPF (I guess so). My intension is to work on same techniques on Web forms.Say I have declared List<Person> personList= new List<Person>() ...

How to translate lists in a MVVM model to ObservableCollections in the View-Model?

I am writing a sample app in WPF and I'd like the Model to be easily reusable in a WinForms app so I'd like to keep WPF specific stuff like INotifyChanged and DependencyObjects out of it. If a Model class has a List of some other Model class, how do I implement the corresponding ObserveableCollection in the View-Model so I can keep my b...