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


ADVERTISEMENT

.net - Converting A CollectionChanged Event Handler Line From C#?

Oct 27, 2011

I've used the developerfusion C# to VB conversion tool to convert Brad Smith's ComboTreeBox project and I'm having troubles on, as is fairly normal for me and C#-to-VB conversions, an event handler.

In the interface implementation for IList(Of ComboTreeNode).Item there is this C# code:

#region IList<ComboTreeNode> Members
public ComboTreeNode this[int index] {
get {

[Code]....

I'm getting errors on the last two lines of the Set method and frankly I don't understand what's even being done, there. It appears, from my limited C# events knowledge, to be adding an event handler back onto the event itself, which leaves me completely lost.

Doing a naive conversion to AddHandler value.Nodes.CollectionChanged, AddressOf CollectionChanged just brings up a reminder that the second argument of AddHandler needs to be a method address.

View 3 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

.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

.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

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

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

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

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

Change Event Not Firing Now?

Jul 1, 2011

The following code was working the other day. Now it isn't. When I type a character in the textbox the event doesn't fire.

[Code]...

why the event would just stop firing?

I'm trying to make it so this the cursor will jump to the next textbox after the user enters 1 character.

View 6 Replies

Change The Key In Key Press/up/down Event?

Jun 21, 2010

I am having a requirement in my project where User press '.' in his num pad and he wants the character ',' to be displayed (dats bcoz he is French User).

I tried changing the e.KeyCode but it is a readonly property.

Is there any other way to change the key in key events?

View 2 Replies

Change The Value In Another Function From Another Event?

Apr 1, 2011

let say i have a function like this

' create filter
Dim colorFilter As New ColorFiltering()
' configure the filter

[code]....

View 9 Replies

DataGridViewComboBoxColumn Change Event For Dgv?

Oct 13, 2011

I have a dgv with several DataGridViewComboBoxColumns and when the user selects an item from one of these (product dropdown), i need it to repopulate another combobox (color dropdown) in the dgv for that same row - based on the value i get from the product dropdown. I've tried using the EditingControlShowing event; however, it only fires when I first select the dropdown .....?

Is this the right event I should be using? My other issue is that I don't know how to have the color dropdown re-populate for just the column and row I've selected. Here's my code so far for this event:

Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
Dim myRowIndex As Integer = 0

[code]....

View 4 Replies

Having A Variable Change As An Event?

Sep 25, 2010

I can't figure out how to make it so that when a variable reaches a certain value, an event is triggered. For example if I wanted a user's level to change to 2 when he gets 1000 exp.

Dim level as integer
Dim exp as integer
*****What do I put here?*****(when exp reaches 1000)
level = 2

View 2 Replies







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