Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I have a DataGrid with ItemsSource bound in XAML to an ObservableConcurrentCollection property.
This allows me to update the collection from a worker thread, and have the changes automatically reflected in my DataGrid.
The problem is that I can only add items to that collection. I need to be able to remove items but I can't find any method that does that.
Does ObservableConcurrentCollection allow removing items? If not, is there an alternative collection I can use?
You should use AsyncObservableCollection which provides feature to update the collection from worker Thread and allows Remove operation. You can read copy the code from https://gist.github.com/thomaslevesque/10023516.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I'm a beginner with wpf app building and entity framework.
I'm building my first wpf app, I found out I should have replaced my auto-generated ICollection with ObservableCollection.
The problem is that I already did most of my code so far but am having some issues with INotifyPropertyChanged. I see all the codes about INotifyPropertyChanged use ObservableCollection.
Is it bad if I go to my auto-generated code now and replace the ICollection with ObservableCollection? Will it mess up my app?
ObservableCollection is only useful if you want to add items to a collection at some point, and have a UI control automatically update to display the added / deleted items. ObservableCollection also has potential threading issues - any change to the collection must be done on the same thread as it was created on.
It has nothing to do with reflecting changes to properties of individual elements within the collection - that is what INotifyPropertyChanged is for.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I have a View - which is a UserControl - that shows different information and gets updated by its corresponding ViewModel.
Now I want to use this View in different other Views, which are UserControls as well.
I tried different approaches like using ResourceDictionaries and other stuff, but I couldnĀ“t get a satisfying result.
You have to put a ContentControl in views that are importing your view and set the ContentControl's Content to the given view
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
In C#/.Net is there a way to reflect from an object, which is a member of a collection up to the collection itself so we can (a) iterate over the other members of the collection, and (b) assuming the collection is itself a member of a collection follow the tree back up to the root?
A typical example would be if there is a common attribute which can be set at multiple levels the collection tree and when an object is changed, find the nearest trunk entry.
The only way to do it is if the type you are working with explicitly has things in it to handle this, in winforms this is handled via the IComponent.Site property. Other libraries may use other standards.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I work in a call center and a few years back I wrote a small app for personal use that helps me keep track of the calls/chats/emails coming in. Well it spread like wildfire and is now used by no less than 100 people. Time for an update.
I am working with data in MSSQL that updates in real time with changes happening at millisecond intervals. I have a timer refreshing a query bound to a DataGridView. One thing I have noticed is that unless I sort by a unique value such as time the sorting is lost when I repopulate the data.
How can I keep that sort order. I do have one 100% unique value called activity_id that I can use as an index.
First, try adding an ORDER BY clause to the SQL statement, if you don't already have one.
Otherwise, you could try sorting on the client side, after setting your DataSource:
dataGridView1.Sort(dataGridView1.Columns["SomeColumnName"], ListSortDirection.Ascending);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
VB6 had a fileListBox with .path property and I am trying to add that property to regular listbox.
ListBox myfilelistbox = new ListBox();
and the one generated with XAML.
I think what you want is Attached Properties
ListBox is a generic control which displays list of items in a linear manner. What you wish to do is to display a hierarchy of items, not a list of them.
There are no such built in controls and you will have to build one for yourself or find some that others have implemented.
Check more information on this other Stack Overflow thread Is there a WPF control which will show a list of files in an Explorer-like view?.
The following article on CodeProject could help you: A WPF File ListView and ComboBox