Is it a good way to realize a MVVM app in WPF? -


i rather new wpf question may confusing... i'm trying realize chat app using jabber.net , follow correct mvvm architecture. have following models: buddylistmodel

chatsessionmodel

chatmessagemodel

the following viewmodels:

buddylistviewmodel

chatsessionsviewmodel

chatmessagesviewmodel

each of vm contains observablecollection<> of corresponding models.

i instanciate jabber in buddylistviewmodel (where i've put login handling) , event handlers (presence,new message) in vm; problem that, doing in way, must call other vms methods (addnewchatsession when new message arrives,....) buddylistviewmodel , don't know if right approach mvvm.

another problem i'm handling messages in single viewmodel , think use filters (in linq, example) show messages in corresponding chatsession. thing?

thanks in advance suggestions !

i'd create applicationviewmodel holds instance of of main model (which may jabber object), , pass instance other vms instantiates can register handle events model raises. (i'm assuming, based on description, when jabber receives message raises event , passes message in eventargs.)

if this, when new message arrives, chatsessionsviewmodel can check see if it's in new session, , create new chatsessionviewmodel if is. chatsessionviewmodel can check message see if belongs session, , add collection of messages if does. these 2 operations independent of 1 another.

i wouldn't put chat messages in single collection , have session view models filter them - filtering items in collection o(n) operation, , if you're building chat client, n going big. it's more logical have chat session examine message comes in , capture if belongs session.

but depends on application. if approach way, there's possibility message come in nothing's handling, , it'll discarded. ok?


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -