Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6104333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:49:48+00:00 2026-05-23T13:49:48+00:00

I am rather new to WPF. I’m trying to realize a chat app using

  • 0

I am rather new to WPF. I’m trying to realize a chat app using Jabber.NET and I would like to follow a correct MVVM architecture. I have the following Models:

BuddyListModel

ChatSessionModel

ChatMessageModel

The following ViewModels:

BuddyListViewModel

ChatSessionsViewModel

ChatMessagesViewModel

Each of the VM contains ObservableCollection<> of corresponding Models.

I instanciate Jabber in BuddyListViewModel (where I’ve put login handling) and all the Event handlers (presence, new message) are in that VM; the problem is that, doing in this way, I must call other VMs methods (AddNewChatSession when a new message arrives,….) from the BuddyListViewModel and I don’t know if this is the right approach for MVVM.

Another problem is that I’m handling ALL the messages in a single ViewModel and think to use filters (in linq, for example) to show the messages in the corresponding ChatSession. Is it a good thing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:49:49+00:00Added an answer on May 23, 2026 at 1:49 pm

    I’d create an ApplicationViewModel that holds the instance of of your main model (which may be the Jabber object), and pass the instance the other VMs it instantiates so that they can register to handle events that model raises. (I’m assuming, based on your description, that when Jabber receives a message it raises an event and passes the message in the EventArgs.)

    If you do this, then when a new message arrives, your ChatSessionsViewModel can check it to see if it’s in a new session, and create a new ChatSessionViewModel if it is. Your ChatSessionViewModel can check the message to see if it belongs to the session, and add it to its collection of messages if it does. These two operations are completely independent of one another.

    I wouldn’t put all the chat messages in a single collection and then have the session view models filter them – filtering items in a collection is an O(n) operation, and if you’re building a chat client, n is going to get very big. It’s much more logical to have the chat session examine the message as it comes in and capture it if it belongs to the session.

    But it really depends on the application. If you approach it this way, there’s the possibility that a message will come in that nothing’s handling, and it’ll get discarded. Is that OK?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When starting out with a new application, would you rather just use an existing
I'm rather new to WPF, so maybe this is a simple question. I have
I am using the new WPF toolkit's Chart to plot large data sets. I
It seems like it would behoove me to learn this GDI replacement, WPF. I
OK, here is the szenario: I'm coding a .NET 3.5 WPF-Aapplication, using the Microsoft
Rather new to trying to get OpenGL ES working on the iPhone, but I've
I joined a new company about a month ago. The company is rather small
I want to use the new report builder 2.0, rather than the old VS2005
Rather than scraping a Ruby version of this algorithm off the net I wanted
A rather odd experience. Using the latest PDK (v7.3) from ActiveState, I used perlctrl

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.