Click here to Skip to main content
15,890,947 members
Home / Discussions / C#
   

C#

 
GeneralRe: netflow collector. Pin
Stephen Lintott15-Aug-08 1:01
Stephen Lintott15-Aug-08 1:01 
QuestionHow to deep-copy the ListCollectionView? Pin
Michael Sync14-Aug-08 22:30
Michael Sync14-Aug-08 22:30 
AnswerRe: How to deep-copy the ListCollectionView? Pin
leppie14-Aug-08 23:36
leppie14-Aug-08 23:36 
GeneralRe: How to deep-copy the ListCollectionView? Pin
Michael Sync14-Aug-08 23:41
Michael Sync14-Aug-08 23:41 
GeneralRe: How to deep-copy the ListCollectionView? Pin
leppie14-Aug-08 23:43
leppie14-Aug-08 23:43 
GeneralRe: How to deep-copy the ListCollectionView? Pin
Michael Sync14-Aug-08 23:48
Michael Sync14-Aug-08 23:48 
GeneralRe: How to deep-copy the ListCollectionView? Pin
leppie15-Aug-08 0:31
leppie15-Aug-08 0:31 
GeneralRe: How to deep-copy the ListCollectionView? Pin
Michael Sync15-Aug-08 18:44
Michael Sync15-Aug-08 18:44 
Sorry for making you confused. Let me elaborate it again..

This is our real scenario...

We are using WPF and Data-binding. We are using ListCollectionView to bind the control (e.g. Datagrid, TreeView or etc) ... The reason why we are using ListCollectionView is that it supports sorting, filtering and etc...

So, our code will be like that. Note: We are using MVVM pattern in our project so we dont want to write the code in code-behind. We wrote the most of code in ViewModel and bind that ViewModel with View..

=====
Class
=====

class Person() : INotification {
private int _id;
private string _Name;
private List<pet> myPets = new List<pet>;

public int ID{
///
}
public string Name{
///
}
public List<pet> MyPets{
//
}
//impelementation for INotification.
}

then.. I bind it with TreeView.

===========
View - XAML
===========

<herichical>
Souce="Pet" // child class
...
/>

<datatemplate>
.... Pet.Name />

<treeview> ItemSouce={... personListViewCollection } //personListViewCollection is the object from code below
...
/>

===========
ViewModel
===========

ListViewCollection personListViewCollection ;

void Constructor(){
populateData();
}

void populateData(){
List<person> persons = new List<person>();

Person p1 = new Person();
p1.ID =1;
..

List<pet> pets = new List<pet>();
pets.Add(new Pet(){ ...... } );
pets.Add(new Pet(){ ...... } );

p1.MyPets.AddRange(pets);

person.Add(p1);

/// add p2 p3 p4


///note: // Let's say personListViewCollection.GetHashCode() == 1000100
personListViewCollection = new ListViewCollection(persons);
}

So, those data will be displayed on TreeView.. then, I wanna re-populatethe data.

void reload(){
List<person> newPersons = new List<person>();


Person newP1 = new Person();
newP1.ID =1;
..

List<pet> newPets = new List<pet>();
newPets.Add(new Pet(){ ...... } );
newPets.Add(new Pet(){ ...... } );

newP1.MyPets.AddRange(newPets);

newPersons.Add(newP1);


///HERE is the problem. I dont want the hashcode of personListViewCollection to change.
personListViewCollection = new ListViewCollection(newPersons); //Problem..
}

then, I want to refresh the treeview and display the new data...

Any Idea?

Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)


GeneralRe: How to deep-copy the ListCollectionView? Pin
N a v a n e e t h15-Aug-08 6:06
N a v a n e e t h15-Aug-08 6:06 
AnswerRe: How to deep-copy the ListCollectionView? Pin
Alaric_15-Aug-08 5:28
professionalAlaric_15-Aug-08 5:28 
GeneralRe: How to deep-copy the ListCollectionView? Pin
Michael Sync15-Aug-08 15:52
Michael Sync15-Aug-08 15:52 
QuestionEscaping Quotes Pin
maliary14-Aug-08 21:52
maliary14-Aug-08 21:52 
AnswerRe: Escaping Quotes Pin
blackjack215014-Aug-08 22:05
blackjack215014-Aug-08 22:05 
GeneralRe: Escaping Quotes Pin
maliary14-Aug-08 22:36
maliary14-Aug-08 22:36 
GeneralRe: Escaping Quotes Pin
Mycroft Holmes14-Aug-08 23:05
professionalMycroft Holmes14-Aug-08 23:05 
GeneralRe: Escaping Quotes Pin
Guffa14-Aug-08 23:27
Guffa14-Aug-08 23:27 
GeneralRe: Escaping Quotes Pin
maliary15-Aug-08 2:36
maliary15-Aug-08 2:36 
GeneralRe: Escaping Quotes [modified] Pin
PIEBALDconsult15-Aug-08 3:18
mvePIEBALDconsult15-Aug-08 3:18 
GeneralRe: Escaping Quotes Pin
Guffa15-Aug-08 5:00
Guffa15-Aug-08 5:00 
GeneralRe: Escaping Quotes Pin
maliary15-Aug-08 22:29
maliary15-Aug-08 22:29 
QuestionBeginInvoke in asynchronous model Pin
George_George14-Aug-08 21:44
George_George14-Aug-08 21:44 
AnswerRe: BeginInvoke in asynchronous model Pin
N a v a n e e t h15-Aug-08 8:24
N a v a n e e t h15-Aug-08 8:24 
GeneralRe: BeginInvoke in asynchronous model Pin
George_George17-Aug-08 20:17
George_George17-Aug-08 20:17 
GeneralRe: BeginInvoke in asynchronous model Pin
N a v a n e e t h18-Aug-08 6:15
N a v a n e e t h18-Aug-08 6:15 
GeneralRe: BeginInvoke in asynchronous model Pin
George_George18-Aug-08 18:47
George_George18-Aug-08 18:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.