bindinglist

What triggers UI to update when ItemsControl.ItemsSource changed?

徘徊边缘 提交于 2019-12-11 12:05:23
问题 I was just looking into the difference between BindingList and ObservableCollection following this question: Why NOT BindingList in WPF As part of this, I tested binding the ItemsSource of an ItemsControl to various types, including List, Collection, ObservableCollection and BindingList. What surprised me is that the interface updated when either the ObservableCollection or the BindingList were modified, but not when the others were. So what is WPF listening to that causes that update? It can

How to update a ListBox if an element was changed c#

随声附和 提交于 2019-12-11 09:59:23
问题 Hi, I'm struggling a bit using the ListBox.DataSource and the INotifyPropertyChanged Interface. I checked several posts about this issue already but I cannot figure out, how to update the view of a ListBox if an element of the bound BindingList is changed. I basically want to change the color of an IndexItem after the content has been parsed. Here the relevant calls in my form: btn_indexAddItem.Click += new EventHandler(btn_indexAddItem_Click); lst_index.DataSource = Indexer.Items; lst_index

How to use a static utility method for property setters in a utility class

本秂侑毒 提交于 2019-12-11 07:49:02
问题 I'm trying to achieve two-way binding between a DataGridView and a BindingList that provides data for the DGV. Some columns do not yet reflect changes in the underlying list and I think it's because I have not provided property setter(s) to notify of property changes. Rather than code the setter for the Rows property the same way I did for the Process property, I'm trying to get more "elegant" and I realize I am stuck.... I stumbled upon a very interesting writeup for a more elegant approach

Binding List and UI controls, not updating on edit

家住魔仙堡 提交于 2019-12-11 02:44:42
问题 I am binding a BindingList two way to a listbox. The Binding list contains a number of images which apparently only update the listbox if items are added or removed from the binding list. How can I make it so that the bindinglist also raises the listchanged event when an item is modified? EDIT: I find the problem I am having is that a property of an object is not being changed, rather the base object. BindingList<ImageSource>(); This wont work however if I did this: BindingList<Image>(); And

C# What is the best way to copy a BindingList?

五迷三道 提交于 2019-12-11 01:55:16
问题 What is the best way to copy a BindingList? Just use ForEach()? Or are there better ways? 回答1: BindingList has a constructor which can take an IList. And BindingList implements IList. So you can just do the following: BindingList newBL = new BindingList(oldBL); Of course that creates a second list that just points at the same objects . If you actually want to clone the objects in the list then you have to do more work. 回答2: Foreach pretty much is the easiest way, and the performance overhead

Update BindingList<> from a background Thread?

↘锁芯ラ 提交于 2019-12-10 17:42:26
问题 I was wondering how I would use the Dispatcher in WPF to safely update my BindingList collection from another thread? I am also open for other solutions, Many Thanks, Kave 回答1: I prefer scheduling a Task to the UI thread. You can get the UI thread scheduler by calling TaskScheduler.FromCurrentSynchronizationContext while on the UI thread. MSDN has an example here. I generally prefer SynchronizationContext -based solutions instead of Dispatcher -based solutions because they are not tied to WPF

Sortable BindingList bound to DataGridView with programmatic sort

♀尐吖头ヾ 提交于 2019-12-10 14:48:48
问题 I have implemented the SortableSearchableList class found at http://msdn.microsoft.com/en-us/library/aa480736.aspx and have added a Sort method to it as follows: public void Sort(PropertyDescriptor prop, ListSortDirection direction) { ApplySortCore(prop, direction); } This class works when sorting my DataGridView by clicking on any of the column headers, but I need to be able to programmatically call the Sort method for a specified column (using a sortButton control in this example). The few

c# BindingList read-only error

丶灬走出姿态 提交于 2019-12-08 20:16:32
问题 I keep trying to look for the possible cause of the problem but I cant seem to find it: Error: System.NotSupportedException: Collection is read-only. at System.ThrowHelper.ThrowNotSupportedException(ExceptionResource resource) at System.Collections.ObjectModel.Collection`1.Add(T item) at WindowsFormsApplication1.Form1.Btn_CSVSEATINGPLAN_Click(Object sender, EventArgs e) in C:\Users\aRJiJon\Documents\Visual Studio 2010\Projects\WindowsFormsApplication_1\WindowsFormsApplication1\Form1.cs:line

How to create a comparable Image

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 13:19:17
I have a DataGridView which has been bound to a generic BindingList . I want to be able to apply sort and search on columns of type DataGridViewImageColumn . The basic idea is to store a name into the image Tag and use is for sorting and searching. How can I do that? It seems several ways to do it: Creating a new class inheriting System.Drawing.Image and making it comparable. Image is an abstract class and if I inherit from it (as well as IComparable interface), I'll encounter with this error message: The type 'System.Drawing.Image' has no constructors defined. What's the problem here? Image

Creating a custom collection that can be bound to a DataGrid

浪尽此生 提交于 2019-12-06 11:08:01
I work for an Architecture firm and I am creating a plug-in for a 3D modeling program to assist design. I have a Building class, and a Floor class. The building contains a reference to a FloorList collection of floors. I'm trying to figure out what to base the FloorList collection off of so that I can minimize the amount of work I need to do to create an interface to edit the collection. The Floor collection represents a series of building floors that are stacked on top of one another. Each Floor has a Floor.Height property that is read write, and an Floor.Elevation property that is read only