observablecollection

WP7 Listbox how UI virtualization work

故事扮演 提交于 2019-12-11 04:37:55
问题 I'm using ListBox which has VirtualizingStackPanel , which is said to support UI virtualizing by default. However, when I set my listStudent (of type ObservableCollection , and have 5 Students in it) as ItemsSource for my Listbox . Then whenever user scroll to the end, I add another 5 Students to my listStudent (and of course UI is notified). But I see that memory consumed keep increased. There's no different from StackPanel in term of memory How UI virtualization work? How to keep memory low

Lock / Unlock ObservableCollection<T>

邮差的信 提交于 2019-12-11 03:55:16
问题 I have a requirement to allow or prevent modification to an ObservableCollection<T> (or at least a type that implements INotifyCollectionChanged for WPF binding) as well as the objects it contains based on a business rule. I can solve the issue of preventing modification to contained objects, but am not sure how to approach preventing change to the collection itself. One option would be to subscribe to the CollectionChanged event and undo changes after they happen, but that is not elegant and

Json.Net Class hierarchy with ObservableCollection and INotifyPropertyChange gets serialized but not deserialized

99封情书 提交于 2019-12-11 03:53:53
问题 I find myself a bit lost on this one. I honestly can't see the error if it's just a class structure doesn't match JSON error. But I doubt it since it's the very same class structure I'm using to create the JSON. If anyone can point me in the right direction, I'd be most greateful. I've created a dotnetfiddle to avoid clutching the question with huge pieces of code. Here's the link: Fiddle I generate that JSON with a console application that gets info on the DB schema. I use a common project

Prevent adding the new Item on ObservableCollection.CollectionChanged event

℡╲_俬逩灬. 提交于 2019-12-11 02:53:47
问题 I need to check some conditions and then decide to add the new Item to my collection or not, is there anyway i can prevent adding in my CollectionChanged event or is it too late at the point? actually i can modify the new Item but can not remove it from the NewItems collection due to runtime exception: protected void MyFilter(object sender, NotifyCollectionChangedEventArgs e) { f (e.Action == NotifyCollectionChangedAction.Add) { foreach (Item item in e.NewItems) { if (!Item.CanBeAdded()) { /

ObservableCollection and CollectionChanged event as WCF datacontract

て烟熏妆下的殇ゞ 提交于 2019-12-11 02:53:39
问题 I use DataContract with ObservableCollection: [DataContract(Namespace = Terms.MyNamespace)] public class MyContract { internal MyContract () { List = new ObservableCollection<string>(); } [DataMember] private ObservableCollection<string> list; [XmlArray("list")] public ObservableCollection<string> List { get { return list; } set { list = value; list.CollectionChanged += (s, e) => { Console.WriteLine("It is never happens!! Why?"); }; } } ... So, when I work with my collection like this.

Filtering ObserverableCollection to display only certain items

我只是一个虾纸丫 提交于 2019-12-11 01:04:08
问题 I was following this link here: http://jacobmsaylor.com/?p=1270 but i'm having problems with it, trying to make tweaks to it <ListBox Name="PageList_ListBox" MouseDoubleClick="PageList_ListBox_OnMouseDoubleClick" Background="#FFC9C9C9" Margin="0,5,0,0" ItemsSource="{Binding PageCollection, ElementName=This}"> . public static ObservableCollection<MLBPage> _PageCollection = new ObservableCollection<MLBPage>(); public static ObservableCollection<MLBPage> PageCollection { get { return

WPF ObservableCollection in xaml

感情迁移 提交于 2019-12-10 23:32:07
问题 I have created an ObservableCollection in the code behind of a user control. It is created when the window loads: private void UserControl_Loaded(object sender, RoutedEventArgs e) { Entities db = new Entities(); ObservableCollection<Image> _imageCollection = new ObservableCollection<Image>(); IEnumerable<library> libraryQuery = from c in db.ElectricalLibraries select c; foreach (ElectricalLibrary c in libraryQuery) { Image finalImage = new Image(); finalImage.Width = 80; BitmapImage logo =

Loading WCF RIA Services Query results to an ObservableCollection

☆樱花仙子☆ 提交于 2019-12-10 22:17:14
问题 In my Silverlight app, after creating ADO.NET Entity Data Model and WCF RIA Services Domain Service Class, in a corresponding ProductService class I have a query operation that returns a collection of Product entities to the client, as follows: public IQueryable<Product> GetProducts() { return this.ObjectContext.Products; } Now I'm trying to read it in the client Silverlight app and load results to an ObservableCollection: ProductContext pcontext = new ProductContext(); ObservableCollection

WPF DataGrid - Combining TimeSeries w/MultiBinding, lose change-notification. Why?

孤街浪徒 提交于 2019-12-10 20:24:33
问题 I have a class that has two ObservableCollection< TimeValue >'s, where TimeValue is a custom DateTime/Value pairing with change-notification (via INotifyPropertyChanged). I call these Targets and Actuals. When I bind these to a chart, everything works perfectly, and I get two LineSeries. If I bind one of them to a DataGrid, with a column for "Date" and a column for "Value", works perfectly again. I even get the TwoWay binding that I need. However, I need to have a DataGrid that has a "Date"

ObservableCollection in ViewModel is not updated when a List changes in Model

时光毁灭记忆、已成空白 提交于 2019-12-10 17:42:20
问题 Let's say I have a model class Data and I would like to create DataViewModel and DataView for it. The data class looks like this: public class Data { public Data() { RandomData = new List<String>(); } public List<String> RandomData {get; set;} } I want to create DataViewModel that encapsulates RandomData property. I need to bind to that RandomData property in some ListView and have it updated when the underlying model's RandomData changes. If I do this: public class DataViewModel { private