Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Recently I picked up Visual C++ /MFC techniques due to business needs. I come up with this question: what is the equivalent concept of CDocument or CView in C#?

I worked on Desktop application in C# before, but I did not think about this CDocuement/CView equivalent concept much.

What I have tried:

I tried MDI and SDI application demo in Visual C++ and googled this question on Internet, but do not get good answer for it...
Posted
Updated 18-Aug-20 7:21am

1 solution

AFAIK / understand,
Quote from Heading 1[^] :
Decoupling presentation logic from application logic is the basic motive behind the Document-View architecture used by MFC applications. For example, assume we use the App Wizard to create an application called Demo (accepting all of the default features). Among the classes generated are CDemoDoc and CDemoView derived from CDocument and CView, respectively:

class CDemoDoc : public CDocument { ... }; // in DemoDoc.h
class CDemoView : public CView { ... }; // in DemoView.h

In C#, there are options like MVC & MVVM as couple of common ones to achieve it. Mostly, winforms use MVC and WPF apps use MVVM architecture to segregate data model, presentation layer and business logic.

Now to take MVC in comparison for example here:
- MVC stands for Model (handles data) - View (responsible to show data to user) - Controller (responsible to get user input and convert into actions on models)

- MFC Document-View has only 2 components. Document is equivalent to model here. View is responsible for both view document and connect to user inputs.

So, high level, MFC View is equal to View-Controller of MVC pattern.
 
Share this answer
 
Comments
Southmountain 19-Aug-20 12:41pm    
I work on C# WinForm application, do you have good links to share for these kinds of examples?
Sandeep Mewara 19-Aug-20 15:44pm    
Try:
https://www.codeproject.com/Articles/383153/The-Model-View-Controller-MVC-Pattern-with-Csharp
https://www.google.com/search?client=firefox-b-d&q=mvc+winforms

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900