.net - LINQ And Static ObservableCollection?

Nov 7, 2011

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

View 2 Replies


ADVERTISEMENT

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.

View 1 Replies

C# Linq Query Conversion For Order An ObservableCollection?

Apr 12, 2012

I've a structure collection like this:

Jet Owner Item Comp
AAAA AAAA 101 2210
AAAA AAAA 202 2220

[code].....

View 1 Replies

.net - Missing ObservableCollection(of T)?

Oct 8, 2009

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?

View 1 Replies

How To Sort An ObservableCollection

Jul 8, 2009

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...

View 1 Replies

Serializing An ObservableCollection(of T) In .Net?

Oct 9, 2009

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?

View 2 Replies

.net - How To Sort A Observablecollection(of String)

May 21, 2012

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)()

View 1 Replies

Bind Textbox To ObservableCollection?

Jun 15, 2011

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]....

View 1 Replies

Wpf - Bind An ObservableCollection To A ComboBox?

May 10, 2012

How do I get even basic binding to work between a ComboBox and an ObservableCollection? I can't get anything but error messages.

VB:

Class MainWindow
Dim Units As New ObservableCollection(Of String)
Private Sub Window_Loaded(sender As System.Object, e As

[Code]....

View 1 Replies

Wpf - Bind More Than One ObservableCollection In XAML

Feb 4, 2012

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)

[Code].....

View 1 Replies

Wpf - ListBox ObservableCollection Duplicating?

Aug 18, 2011

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()

[Code]...

View 1 Replies

Wpf - Multi-threaded ObservableCollection In VB

Jul 14, 2010

This is my attempt to create a ObservableCollection in VB that is WPF thread-safe. Can you think of any problems it may have?

[Code]...

View 2 Replies

WPF Binding Listview To A ObservableCollection?

May 3, 2011

I'm trying to figure out what I need to change to bind this code to a listview.

XAML:

<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

[code]....

what I need to do to change my XAML to Bind to my data.

View 2 Replies

WPF Unique Entries In An ObservableCollection

May 13, 2011

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.

[Code]...

View 1 Replies

Asp.net - Listbox Bound To ObservableCollection (in .NET And Silverlight)?

Jan 9, 2011

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.

View 1 Replies

Bind ObservableCollection To A DataObjectProvider In XAML?

Sep 14, 2011

I want to bind data to an objectdataprovider.[code]...

View 1 Replies

C# - ObservableCollection.Contains() Doesn't Work Correctly?

Dec 31, 2011

Consider the following:

class Bind
{
public string x { get; set; }

[code].....

View 4 Replies

Cannot Change ObservableCollection During An CollectionChanged Event

Mar 15, 2012

I have a CollectionChanged Handler Method:

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?

View 1 Replies

Notifying The View Of A Change To An Element Within An ObservableCollection?

Jul 28, 2010

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?

View 1 Replies

Two-way WPF Binding To Properties Of A Class Inside Of An ObservableCollection

Nov 17, 2011

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.

View 1 Replies

Wpf - Convert C# ObservableCollection Sample To Dataset Or Equivalent

Feb 23, 2011

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".

[Code]...

View 1 Replies

Wpf - Inserting Data To XML File Notify ObservableCollection

Feb 4, 2011

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?

View 1 Replies

ObservableCollection.Insert On Index Bigger Than Length Of Collection

Mar 15, 2012

I'm wondering, what happens when you do following:

Collection.Insert(55, "Input")

The collection contains 20 items, so 19 would be the last index. This doesn't work, I get the expected outofrangeException. But when I do :

Collection.Insert(20, "Input")

That works without a problem, even though it is 1 out of the collection.

View 1 Replies

Wpf - Refresh TreeView CollectionViewSource ObservableCollection Item Changed

Apr 23, 2011

I have the following setup for a treeview:

<local:BuddyManager x:Key="bmBuddyManager" />
<CollectionViewSource x:Key="cvsBuddyManager"
Source="{Binding Source={StaticResource bmBuddyManager}, Path=Buddies}">

[Code]....

The Binding and grouping work well, the only issue is when I set a particular 'buddy' to online or blocked the child nodes do not move or change.

I am trying to get this to work like an MSN Treeview where people go offline and online.

View 1 Replies

C# - ObservableCollection Doesn't Support AddRange Method - Get Notified For Each Item Added Besides What About INotifyCollectionChanging?

Mar 22, 2009

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').

[Code]...

View 6 Replies

Static Constructor In .Net?

Feb 9, 2010

I am rewriting a C# class in VB. The C# class has a static constructor in it:

static Class()
{
...
}

which, through the Call Stack, I found is called by the main window's InitializeComponent() method.Everywhere I've looked has told me that the corresponding static constructor in VB is just:Shared Sub New()

but this method is never invoked. Am I creating my VB static constructor right? Is it likely something else that has nothing to do with my static constructor?

View 1 Replies

Static Variable In Asp.net?

Dec 15, 2011

I am writing a code for a webapplication in vb.net. I am using a shared variable in the vb code.

Consider the static variable value is 3 for a user who hits the web application. Again when another user hits the same web application, whether the static variable will be 3 again or whether he will have a separate value for static variable for his session?

View 1 Replies

.net - ActiveRecord Linq/NHibernate Linq Not Building Query Completely?

Jul 14, 2011

given this function:

Public Function Search(ByVal StartIndex As Integer, _
ByVal MaxResults As Integer, _
ByVal AccountNumber As String, _
ByVal LastName As String, _

[Code]....

instead of what I expected:

Select count(*) from remitline where lastname = "smith"

What am I doing wrong building up the where clause? I'm using Castle ActiveRecord 2.1

View 1 Replies

Performance Gain In LINQ Query Vs LINQ Stored Procedure?

Aug 6, 2009

if there is that much of a performance gain in running a LINQ stored procedure versus a LINQ query?

View 1 Replies

.net - Static DateTime For Testing?

Dec 11, 2009

We have a DateTime Service that pulls the Database date down when we need to use a Date. Now, If I want to run a test using "Todays" Date using FitNesse, What would be the easiest way of creating a way to have (OurService).CurrentDate be static? We have a control that ads Days,Years, or Months to the current date.. and I would like to be able to test this.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved