observablecollection

How to detect property changes in items contained in ObservableCollection<T> [duplicate]

对着背影说爱祢 提交于 2019-12-13 07:17:38
问题 This question already has answers here : ItemPropertyChanged not working on observableCollection.Why? (2 answers) Closed 3 years ago . private ObservableCollection<Employee> models = new ObservableCollection<Employee>(); My model has 2 fields ( Name and a boolean field called activeDuty ) In my constructor, I this.models.CollectionChanged += this.OnCollectionChanged; void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) void OnItemPropertyChanged(object sender,

Change out ObservableCollection upon ComboBox change

故事扮演 提交于 2019-12-13 07:09:42
问题 This is not so much a question that I am stuck on, but a question as to if there is a better way. It works as it stands, but I want to get a better understand if I could. Why do I always have to update the DataGrid.ItemSource when I am using an ObservableCollection<T> for binding? I am binding the ObservableCollection<T> to the DataGrid using the below code. public partial class MainWindow : INotifyPropertyChanged { public MainWindow() { DataContext = this; InitializeComponent();

How to bind ObservableCollection with Listbox in WPF

百般思念 提交于 2019-12-13 05:24:27
问题 I would like to bind ObservableCollection with Listbox in WPF application. So when elements in the ObservableCollection will be modified the ListBox will update itself. There is a public static ObservableCollection<Camera> extension = new ObservableCollection<Camera>(); in class Camera And the ListBox is in the class MainWindow.xaml I tried that, but it does not work: Camera class: using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System

Update UI when adding to observable collection

巧了我就是萌 提交于 2019-12-13 04:38:20
问题 iv'e got 2 itemscontrols bound to 2 observable collections my ItemsControls : <ItemsControl Grid.Column="4" Name="Pipe19" ItemsSource="{Binding Path=Pipes[19].Checkers}" Style="{StaticResource ItemsControlStyle}" ItemsPanel="{StaticResource TopPipePanelTemplate}" /> <ItemsControl Grid.Column="5" Name="Pipe18" ItemsSource="{Binding Path=Pipes[18].Checkers}" Style="{StaticResource ItemsControlStyle}" ItemsPanel="{StaticResource TopPipePanelTemplate}" /> their definitions through style : <Style

Notify PropertyChanged after object update

大城市里の小女人 提交于 2019-12-13 04:36:23
问题 I wish to update my listview in an elegant way. This is my code: ObservableCollection<Track> tracks = new ObservableCollection<Track>(); Track track = new Track(); Tracks.AddRange(track); // collection add a track, and list view updates too Task.Factory.StartNew(() => track.GetInfo(); // this operation might require some times to update // here I need to notify that my object is updated ); How i can force to update binding of an object inside my ObservableCollection ? This is my userControl

Pivot an observable collection [duplicate]

微笑、不失礼 提交于 2019-12-13 02:18:29
问题 This question already has answers here : Is it possible to Pivot data using LINQ? (6 answers) Closed 6 years ago . I have records like this in observable collection ID Department salary joingdate 1 .NET 5000 04/08/2011 2 .NET 6000 04/07/2011 3 JAVA 7000 04/08/2011 4 JAVA 8000 04/07/2011 5 .NET 9000 04/06/2011 now I want new observable collection like Joingdate .NET(Salary) JAVA(Salary) 04/08/2011 5000 7000 04/07/2011 6000 8000 04/06/2011 9000 NULL How would I get this type of observable

Multiple Views of Observable Collection with Datagrid

筅森魡賤 提交于 2019-12-13 00:42:34
问题 I have the same problem like this. But I´m using a DataGrid instead of a ListBox and it does not seem to work like this (it might also be because i never used visual basic and didnt translate the code correcly into c#). I basicly want two DataGrids on the same data with different filters. ICollectionView view_dataLinesUnfiltered; ICollectionView view_dataLinesFiltered; public MainWindow() { ... //view_dataLines = CollectionViewSource.GetDefaultView(dataLines); // <- Filter works on both view

Finding an ObservableCollection for given/dynamic type via reflection

僤鯓⒐⒋嵵緔 提交于 2019-12-12 19:00:06
问题 I have a Class with several ObservableCollections for different types. Now, I want to find the correct Collection for a given type via reflection, because I don't want to build an if-monster which I have to update every time I add another Collection. This method was the first step: public ObservableCollection<T> GetObservableCollectionForType<T>() { foreach (PropertyInfo info in this.GetType().GetProperties()) { if (info.GetGetMethod() != null && info.PropertyType == typeof

Finding an index in an ObservableCollection

流过昼夜 提交于 2019-12-12 17:40:51
问题 This may be very simple but I have not been able to come up with a solution. I am have a: ObservableCollection<ProcessModel> _collection = new ObservableCollection<ProcessModel>(); This collection is populated, with many ProcessModel's. My question is that I have an ProcessModel, which I want to find in my _collection. I want to do this so I am able to find the index of where the ProcessModel was in the _collection, I am really unsure how to do this. I want to do this because I want to get at

I get an exception when trying to swap elements in an observable list?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 17:14:56
问题 I have the following code, which seems very simple and straight-forward: public static void main(String[] args) { Series<String, Number> series = new Series<String, Number>(); ObservableList<Data<String, Number>> list = series.getData(); list.add(new Data<String,Number>("1", new Double(1))); list.add(new Data<String,Number>("2", new Double(2))); list.add(new Data<String,Number>("3", new Double(3))); list.add(new Data<String,Number>("4", new Double(4))); int size = list.size(); for (int i = 0;