observablecollection

Is there a way to convert an observable collection to regular collection?

做~自己de王妃 提交于 2019-12-18 05:57:31
问题 I've got a test collection setup as : ObservableCollection<Person> MyselectedPeople = new ObservableCollection<Person>(); public MainWindow() { InitializeComponent(); FillData(); } public void FillData() { Person p1 = new Person(); p1.NameFirst = "John"; p1.NameLast = "Doe"; p1.Address = "123 Main Street"; p1.City = "Wilmington"; p1.DOBTimeStamp = DateTime.Parse("04/12/1968").Date; p1.EyeColor = "Blue"; p1.Height = "601"; p1.HairColor = "BRN"; MyselectedPeople.Add(p1); } Once I have this

Bind an ObservableCollection to a ListView

流过昼夜 提交于 2019-12-18 05:55:46
问题 I am having an immense amount of trouble getting my data to bind correctly. I have read most the posts on here from people with similar issues, but for some reason I just can't get it to click. The XML for my table is: <Window ... DataContext="{Binding RelativeSource={RelativeSource Self}}" > ... <ListView Height="124" HorizontalAlignment="Left" Margin="12,46,0,0" Name="listViewDocuments" VerticalAlignment="Top" Width="Auto" DataContext="{Binding DocumentList}"> <ListView.View> <GridView>

ObservableCollection dependency property does not update when item in collection is deleted

☆樱花仙子☆ 提交于 2019-12-17 18:26:18
问题 I have a attached property of type ObservableCollection on a control. If I add or remove items from the collection, the ui does not update. However if I replace the collection within with a new one the ViewModel the ui does update. Can someone give me an example of what I need to do within the Dependency object so that it can handle changes within the collection? Part of the dependency object is listed below: public class RadCalendarBehavior : DependencyObject { private static void

Long List Selector Observable Collection and Visual Tree - problems?

佐手、 提交于 2019-12-17 17:16:14
问题 I've made a short example to show where I've encoutered some problems. They concers LongsListSelector bound to ObservableCollection (no matter what type items are). I've set long list item template as (for example) a textblock, I've also made three buttons - to add one element to collection, to remove one last, and to search through visuall tree. The code is not so long so I'll post it here below (if you want whole example it's at: http://sdrv.ms/163TYEG ). XAML (except headers): <phone

Datagrid Column header should check / uncheck CheckBox’s state depending upon whether all CheckBoxes of a DataGridView column are checked or unchecked

江枫思渺然 提交于 2019-12-17 16:30:42
问题 The problem i'm stuck with is related to checkbox in DataGrid(WPF). I've attached the screenshot for better understanding of the problem. Problem: The DataHeader Column Checkbox is checked even when one of the child is Unchecked. I expect the solution to fix this so that when one of the child is unchecked explicitly by the user, The ALL(Column Header) should be unchecked implicitly. Please help guys... Thank You Plz check the link. i want the solution to work like this. http://www.codeproject

Binding WPF Canvas Children to an ObservableCollection

不羁岁月 提交于 2019-12-17 15:57:17
问题 In my WPF application I have a Canvas in which I do some drawing. Earlier I handled the drawing in the code behind, but now I've factored everything out to a ViewModel. This gives me some challenges.. I have a few InkPresenter objects holding Strokes. Earier I added them as children to the Canvas in the code behind - like this: // Build an InkPresenter: var someInkPresenter = BuildInkPresenter(..); //_myCanvas is the <Canvas> I want to display it in: _myCanvas.Children.Add(someInkPresenter);

Filter an observable collection

丶灬走出姿态 提交于 2019-12-17 15:52:10
问题 I have a ListView control that displays items from an observable collection. These items need to be filtered. I am able to do that with a CollectionViewSource , but the filter needs to be updated each time an item changes. My items looks like this: enum Status {Done, Failed, Skipped, ...} class Project { public string Name {get;set;} public Status Status {get;set;} // etc. etc. } class ProjectViewModel : INotifyPropertyChanged { private Project project; public ProjectBuildInfoViewModel

How to make ObservableCollection thread-safe?

天涯浪子 提交于 2019-12-17 06:36:09
问题 System.InvalidOperationException: Collection was modified; enumeration operation may not execute. I am adding/removing from an ObservableCollection which is not on a UI thread. I have a method names EnqueueReport to add to the colleciton and a DequeueReport to remove from the colleciton. The flow of steps is as below :- 1.call EnqueueReport whenever a new report is requested call a method every few seconds to check if the report is generated (this has a foreach loop that checks the generated

How to make ObservableCollection thread-safe?

谁说我不能喝 提交于 2019-12-17 06:36:06
问题 System.InvalidOperationException: Collection was modified; enumeration operation may not execute. I am adding/removing from an ObservableCollection which is not on a UI thread. I have a method names EnqueueReport to add to the colleciton and a DequeueReport to remove from the colleciton. The flow of steps is as below :- 1.call EnqueueReport whenever a new report is requested call a method every few seconds to check if the report is generated (this has a foreach loop that checks the generated

How do I sort an observable collection?

浪尽此生 提交于 2019-12-17 03:56:06
问题 I have a following class : [DataContract] public class Pair<TKey, TValue> : INotifyPropertyChanged, IDisposable { public Pair(TKey key, TValue value) { Key = key; Value = value; } #region Properties [DataMember] public TKey Key { get { return m_key; } set { m_key = value; OnPropertyChanged("Key"); } } [DataMember] public TValue Value { get { return m_value; } set { m_value = value; OnPropertyChanged("Value"); } } #endregion #region Fields private TKey m_key; private TValue m_value; #endregion