Technology Stack
C++/CX
Visual C++ component extensions for UWP development
XAML
UI framework for building adaptive, responsive interfaces
UWP
Universal Windows Platform for modern Windows apps
MVVM
Design pattern for separating UI from business logic
Project Structure
The Calculator application is organized into three main Visual Studio projects:Calculator Project (View)
Contains the XAML-based user interface:- MainPage.xaml - Root container page
- Calculator.xaml - Standard/Scientific/Programmer modes
- DateCalculator.xaml - Date calculation mode
- UnitConverter.xaml - All converter modes
- Custom controls and visual resources
Despite having multiple calculator modes, the app uses only one concrete Page class (MainPage) that hosts different UserControls.
CalcViewModel Project (ViewModel)
Provides data binding and UI state management:- ApplicationViewModel - Root ViewModel for MainPage
- StandardCalculatorViewModel - Standard/Scientific/Programmer modes
- DateCalculatorViewModel - Date calculations
- UnitConverterViewModel - All converter modes including currency
CalcManager Project (Model)
Contains the calculation engine with three layers:Architecture Diagram
Key Architectural Principles
Separation of Concerns
Separation of Concerns
Each layer has a distinct responsibility:
- View: Rendering UI and capturing user input
- ViewModel: Exposing data for binding and handling UI logic
- Model: Performing calculations and managing data
Data Binding
Data Binding
XAML elements bind directly to ViewModel properties using
x:Bind markup extension, eliminating the need for manual UI updates.Property Change Notification
Property Change Notification
ViewModels implement
INotifyPropertyChanged to automatically notify the UI when data changes.Adaptive UI
Adaptive UI
VisualStates adapt the interface based on window size, orientation, and mode.
Application Entry Point
The application starts inApp.xaml.cs:
src/Calculator/App.xaml.cs
MainPage, which then loads the appropriate UserControl based on the selected mode.
Mode Management
Calculator supports multiple modes through a unified architecture:Calculator Modes
- Standard
- Scientific
- Programmer
Utility Modes
- Date Calculator
- Unit Converters
- Currency Converter
Mode property on ApplicationViewModel, which initializes the appropriate child ViewModel and loads the corresponding UserControl.
Next Steps
MVVM Pattern
Learn how MVVM works in Calculator
View Layer
Explore XAML and UI components
ViewModel Layer
Understand data binding and properties
Model Layer
Dive into the calculation engine