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 3875518
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:16:34+00:00 2026-05-19T22:16:34+00:00

I am currently developing a new WPF application and have the majority of my

  • 0

I am currently developing a new WPF application and have the majority of my business logic layer developed (ie my Models).

I am about implement ViewModel classes to represent one feature of my application. I am quite new to the Model-View-ViewModel pattern and I have a question about which approach would be best to use when implementing my ViewModel classes.

From examples online I have been finding that often the Model is a member of the ViewModel. Using this approach, the ViewModel exposes the properties of the Model-member so that they can be bound to the Model in the View.

For example:

Public Class MyViewModel
  Implements INotifyPropertyChanged

  Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

  Private _myModel As ModelClass

  Public Property MyModelPropertyA As Object
    Get
      Return _myModel.MyModelPropertyA
    End Get
    Set(ByVal value As Object)
      _myModel.MyModelPropertyA = value
      RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("MyModelPropertyA")
    End Set
  Public Property MyModelPropertyB As Object
    Get
      Return _myModel.MyModelPropertyB
    End Get
    Set(ByVal value As Object)
      _myModel.MyModelPropertyB = value
      RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("MyModelPropertyB")
    End Set
    '.... And so On'

End Class

What I don’t like about this approach is the fact that there are a lot of properties that I will be re-writing.

So, I am considering the option of Inheriting the model class in the ViewModel instead of using a private member.

Like So:

Public Class MyViewModel
      Inherits MyModel
      Implements INotifyPropertyChanged

      Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

      'Now all of my properties are inherited'
End Class

The problem with the second approach is that I’m not sure how to convert my models into view models while the application is running.

You can’t set viewModelInstance = ModelInstance.

(But you can set modelInstance = viewModelInstance)

I’m looking for advice on the best approach on how to implement the ViewModel classes.

  • 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-19T22:16:35+00:00Added an answer on May 19, 2026 at 10:16 pm

    Do not even think about inheriting your viewModel from model – this will be a hack which nobody will like. If you are too lazy too expose all the properties (BTW resharper can do it automatically) then you can include your model into your viewModel and provide an access to it via some readonly property. But you should still have INotifyPropertyChanged implemented in model class.

    Some code (sorry for C#):

    class Model : INotifyPropertyChanged
    {
        public string Name { get; set; } // this raises PropertyChanged
    }
    
    class ViewModel
    {
        private readonly Model _model;
    
        public Model Model { get { return _model; } }
    }
    

    View XAML:

    <Textbox Text="{Binding Model.Name}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently developing a application where I will have multiple windows open using C#
i'm developing an application (wpf) that have 3 windows. in the main window user
I'm currently developing a new web application. This is the first time I'm using
I'm new to wordpress and currently developing a theme on it. I have noticed
I am currently developing a new website and have problems with IE7. First image
Currently we're developing a new Web Application. Customer says that it should support at
I am new to Eclipse. Currently developing a sample web application using primefaces 3.1
I am currently developing an application in C# using WPF. I need the program
Hello i am currently developing a ASP.NET MVC 3 application that uses the new
fellow programmers! I'm new... hope you can help! So. I'm currently developing an application

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.