Wpf - .NET Using LINQ To Transpose An ObservableCollection?
Aug 11, 2010
I have a custom item class (basically two string values with associated properties), as below:
Public Class itmDataDetails
Private _strDataName As String
Private _strDataValue As String
Public Property strDataName() As String
[Code]...
Naturally, this doesn't work as x cannot be added to the ObservableCollection(Of itmDataDetails). Any suggestions on how to accomplish this? I don't know LINQ that well, so I wouldn't be surprised to discover I'm doing it wrong.
This will probably be a basic questions for the LINQ & architecture experts however I am failing to understand a problem i've encounted when trying to update a 'Static ObservableCollection.
Me.Grid1.ItemsSource = ContactList Me.Grid2.ItemsSource = From s In ContactList Where s.ContactTypes.Any(Function(t) t.ContactTypeName = "Christmas List")
If I add a new Contact with the ContactType "Christmas List" to the ContactList ObservableCollection, Grid1 reflects the additional Contact however Grid2 does not reflect the change unless I rebind.
Anyway to Reflect the change in Grid2 to show the new Contact with the queried ContactType
I have this problem with this macro. I think it's a VERY common problem, but I just kind find a straight answer since it's so specific.
I have data like this: juanA50 juanB60 juanD70 pedroA50 pedroC70 pedroD80 pedroF90 felipeA50 felipeH100 felipeL200
The first column is the name of the employee. The second one contains the name of payment concepts (salaries, insurance, etc). The third column contains the actual amount to be charged or discharged.
The desired output should be like this: ___A_B_C_D_E_F_H_L juan_50_60__70___ pedro_50__70_80__90__ felipe_50____100_200
Delete duplicated values in the names, merge the matching rows of an employee and put them in the correct colum that matches the payment concept. I'm using SQL Server 2000 and Excel 2007, so feel free to talk about querys and Excel 2007 new functions. This is done with a VB6 application (not VBA), so I'm using Excel's object model as a reference in my project. I was originally trying to do it with SQL Server, instead with a macro, but I couldn't find a way.
I tried using the linq Zip method on IEnumerable but it does not work for more than 2 arrays.Here is an example in Python of what I am trying to do(I got p - nested IEnumerable - and need q - another nested IEnumerable):
I'm doing an experiment on WPF and MVVM, and while coding the ViewModel on Vb.net I noticed this red wavy lines under my ObservableCollection(of T)s T_T
Anyway, the application is in WPF & VB.Net, under the .Net Framework 3.5 (I checked) and I have an 'Imports System.Collections.ObjectModel' on top of my class. Intellisense shows the other classes on System.Collections.ObjectModel except ObservableCollection.
Here's a screenshot.
So, why is ObservableCollection(of T) missing and how do I make it appear?
I have a WPF app which binds a System.Collections.ObjectModel.ObservableCollection to a listbox. This ObservableCollection contains instances of my own class (named DataContractsUserObject) and at runtime when I add an object to this collection it automatically appears in the listbox because of the binding. The problem is that it always appears at the bottom of the list and I would like it to appear alphabetically sorted as the existing items in the listbox are.So I tried to sort the collection by doing this after I add an item to it:[code]but of course that is not actually sorting the original collection is it, its just sorting a new instance that is in a Generic.List format. Whilst I probably could just do that and then set that new list instance back as the source of the listbox binding, that will cause all of the items to be reloaded (and when each item in the listbox is loaded it animates in, so it would look stupid having all items animate in again just because one has been added).
The ObservableCollection class itself does not have a Sort method and although I know how to implement my own comparison class (using IComparer) I dont know how to make this work on an ObservableCollection without doign ToList or ToArray etc.[code]Just found this that looks like it might be of some use url...
I'm trying out MVVM in VB.Net for a while now and started out with some of my entities using List(of T)s, which I xml serialized to disk. Now, I updated the classes used by the Lists to implement INotifyPropertyChanged so I also changed the List(of T)s to ObservableCollection(of T)s.After which, the XML serializer stopped working :'( A colleague told me that ObservableCollections, unlike generic Lists, are not serializable.If so then how can I make them Serializable?
All I need is a simple way to sort the strings in the collection. I can't find anything online. Everybody is using lamda expressions which I don't think works for just a string collection?
Public Property FilterCollection As New ObservableCollection(Of String)
From d In FilterCollection Order By (Function(d) d)()
I'm trying to get bind a textbox text property to an observable collection, and report changes back to the collection. The ContactLog property gets set from the calling page.[code]....
How can I implement both of these ObservableCollections in my xaml? I want to have a listview with all my students, and another listview with all my teachers.For now I just made an example student and teacher object. Am I going about this the wrong way. Eventually I will pulling from a datatable, not sure how I would implement it to the ObservableCollection though.
Public Class PersonalViewModel Public Sub New() Dim obcollection1 As New ObservableCollection(Of Student)
I have a WPF application which has a listbox bound to an ObservableCollection which retrieves it's data from a Database. I am attempting to have the ListBox data refreshed every minute through the use of a DispatcherTimer.
Dim dispatcherTimer As DispatcherTimer = New System.Windows.Threading.DispatcherTimer AddHandler dispatcherTimer.Tick, AddressOf getRoomMeetingDetails dispatcherTimer.Interval = New TimeSpan(0, 2, 0) dispatcherTimer.Start()
I have an ObservableCollection of class Customers that I fill from a database query. Because of how the tables are joined, I sometimes get one off entries (Bill has a shipping address that is different than his mailing address) that show up in the data twice.Each customer row has an ID as unique primary key, and this is what I use to pull up more customer information when someone selects a row from the bound ListView. In the WinForms version of this program, I would search the ListView for the CustomerID, and if it was found I would avoid inserting it a second time.
I'm trying to bind a listbox to an ObservableCollection and keep the listbox updated when items are added to the collection. I have a class called CollectionOfBlogs:
Public Class CollectionOfBlogs Implements INotifyPropertyChanged Public Event PropertyChanged As PropertyChangedEventHandler _ Implements INotifyPropertyChanged.PropertyChanged
[code]....
Beyond this, I have a simple textbox and button on a page. When a name is entered into the textbox, and the button is clicked, I call the addBlog(passing in name from textbox) sub routine in the ITRSBlogs Class (back up the page a bit) to add the item to the collection.Problem is, when I add an item to the collection, the listbox is not updated.
Private Sub LayersChanged(sender As Object, e As Collections.Specialized.NotifyCollectionChangedEventArgs) If e.ItemCollectionHasNewItems IsNot Nothing Then
[Code]....
I cant call SomethingRelatedToE.excecute because it effects e's collection which causes a runtime error.
However if the LayersChanged method has completed I can then call SomethingRelatedToE.execute from another method without effecting it.
Is there a way for me to directly move to another method after the LayersChanged method has finished, like a Goto function or another solution to this?
Calling OnPropertyChanged for an ObservableCollection only works when there has been some change to the properties of the collection, not the objects it contains (add, remove, clear, etc).
Is there any way to notify the View that there has been a change to an item within the collection?
I've searched as best as I can, and I can't find an answer to this specific problem that I have... WPF binding seems to be great and all, but I end up banging my head against the wall more often than not.
Okay, I have a singleton class which is ultimately the one that I'm binding to:
Imports System.ComponentModel Imports System.Collections.ObjectModel Public Class AmandaSeyfried
[Code].....
If I throw some break points on the Getter and Setters of the CountryTranslation class, I can monitor when they're being changed (via the datagrid, so binding is working), but try as I might I can't figure out how to raise an event based upon that back in the main class to subsequently update the datastore to show the changes.
I have a C# example that is populating a multiselect combobox. This was from an example found online. It works fine with the static values coming from the observable collection. I want to change this to be database driven from a SQL Server backend, but was having issues. I did get it to populate the combobox, but the selection is acting kind of screwy. Some type of simple query from a Northwind table would suffice such as: "Select CategoryName from Categories".
I have a parent window which has a ListView that is bound to an ObservableCollection that gets it's data from an XML file. On the parent window, I have an add button that opens a opens a Modal Window (form2.ShowDialog(), I think this is a Modal window).
In the child window I have a few text fields and an add button, the user enters data for a new record and clicks the Add button and the XML file is updated with the new record.
What I am seeking to do is when the child window is closed that the ListView in the parent window is refreshed to show the new record.
When I am updating the XML file from the child window, I am doing this directly to the XML file, should I be adding the data to the file in some other manner which would raise an event on the ObservableCollection?
I was heading down the path of adding an event handler to the add button on the parent window and attempt to force a re-read of the XML file, but I cannot figure out how to achieve this, below is what I have done so far.
form1.xaml.vb:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click Dim frm As New newEmergencyContact
[Code]....
I cannot workout what should go into the refresh_EmContacts sub, do I need to call some kind of ObservableCollection event handler to notify it that it has been updated and to do the re-read?
I want to be able to add a range and get updated for the entire bulk. I also want to be able to cancel the action before it's done (i.e. collection changing besides the 'changed').