# dingpingzhang/wpfextensions architecture

> Architecture diagram of the GitHub repository dingpingzhang/wpfextensions, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dingpingzhang/wpfextensions
- Repository: https://github.com/dingpingzhang/wpfextensions

## Overview

##### Project type and purpose
- This is an open-source toolkit of reusable WPF/XAML extensions and MVVM helper libraries.
- It consists of three distinct NuGet-packaged modules:
- WpfExtensions.Xaml – a collection of XAML MarkupExtension classes (CommandExtension, ComposeExtension, IfExtension, SwitchExtension, I18nExtension, etc.)
- WpfExtensions.Binding – a Vue-3-style reactivity engine (Watch, WatchDeep, Computed) for INotifyPropertyChanged/INotifyCollectionChanged objects
- WpfExtensions.Infrastructure – assorted MVVM‐and‐general utilities (RelayCommand, async locking, DI interfaces, logging, configuration, extension methods)
- There is also a Tests project covering the Binding module’s behavior.

##### File structure
- Top-level solution contains:
- Three library projects under WpfExtensions.*
- A Tests directory targeting WpfExtensions.Binding
- Each library project has its own .csproj, source files grouped by feature folders (e.g. Converters, Commands, Mvvm).
- No executable front-end; these are framework-level components.

##### Extract insights from the README
- It confirms the three modules and describes key features of each.
- Emphasizes that these are syntactic-sugar supplements for WPF MVVM and should also work on other XAML platforms.
- No runtime orchestration or microservices – purely class libraries.

- Consumer Application (any WPF/UWP/Maui app)
- WpfExtensions.Xaml module
- WpfExtensions.Binding module
- WpfExtensions.Infrastructure module
- .NET / WPF Runtime (presentation layer, XAML parser)
- Unit Tests (tests/Binding)
- Consumer App ↔ XAML parser (loads views, invokes MarkupExtensions)
- XAML parser → WpfExtensions.Xaml (resolves markup extensions to CLR objects)
- ViewModels in Consumer App → WpfExtensions.Binding (Computed, Watch, WatchDeep subscribe to INotifyPropertyChanged)
- Consumer App → WpfExtensions.Infrastructure (uses RelayCommand, DI interfaces, logging, extension methods)
- WpfExtensions.* modules may reference each other (Infrastructure is used by Xaml and Binding modules for shared utilities)
- Unit Tests → WpfExtensions.Binding (validate reactivity behaviors)
c. Architectural patterns & principles
- Layered libraries: separation of concerns between XAML, reactivity, and general utilities
- Observer pattern: INotifyPropertyChanged for reactivity
- Command pattern: RelayCommand and CommandExtension
- Extension methods and MarkupExtension patterns to augment the WPF framework without modifying it
- MVVM supportive interfaces (IViewLoadedAndUnloadedAware, ITabItemSelectionChangedAware)
d. Key technologies/frameworks
- .NET Standard / .NET 5+ (class libraries)
- WPF Presentation Framework, XAML MarkupExtension base class
- INotifyPropertyChanged / INotifyCollectionChanged
- MVVM conventions (commands, view‐model resolution, tab control helpers)
- Unit testing via xUnit/NUnit (Tests project)

##### Detailed yet focused
- Every public-facing submodule is represented (Markup, Commands, Reactivity, MVVM, Logging, Async)
- Don’t dive into individual classes beyond grouping; concentrate on module boundaries and interactions

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Consumer Application
    ConsumerApp["Consumer Application"]:::external

    %% Runtime Layer
    subgraph "Runtime (.NET/WPF)" 
        direction TB
        WPFRuntime[".NET / WPF Runtime"]:::runtime
    end

    %% Modules Layer
    subgraph "Modules (NuGet Packages)"
        direction TB

        subgraph "WpfExtensions.Xaml" 
            direction TB
            XamlModule["WpfExtensions.Xaml Module"]:::xaml
            Converters["Converters"]:::xaml
            ExtensionMethodsXaml["ExtensionMethods"]:::xaml
            Markup["MarkupExtensions"]:::xaml
            I18nManager["I18nManager.cs"]:::xaml
            I18nSource["I18nSource.cs"]:::xaml
            XamlModule --> Converters
            XamlModule --> ExtensionMethodsXaml
            XamlModule --> Markup
            XamlModule --> I18nManager
            XamlModule --> I18nSource
        end

        subgraph "WpfExtensions.Binding"
            direction TB
            BindingModule["WpfExtensions.Binding Module"]:::binding
            CoreReactivity["Core Reactivity Types"]:::binding
            ASTNodes["AST/Node Implementations"]:::binding
            BindingExt["Extensions & Helpers"]:::binding
            BindingModule --> CoreReactivity
            BindingModule --> ASTNodes
            BindingModule --> BindingExt
        end

        subgraph "WpfExtensions.Infrastructure"
            direction TB
            InfraModule["WpfExtensions.Infrastructure Module"]:::infra
            Commands["Commands Submodule"]:::infra
            ExtInfra["ExtensionMethods"]:::infra
            MvvmHelpers["MVVM Helpers"]:::infra
            Utilities["Utilities & Interfaces"]:::infra
            InfraModule --> Commands
            InfraModule --> ExtInfra
            InfraModule --> MvvmHelpers
            InfraModule --> Utilities
        end
    end

    %% Tests Layer
    subgraph "Tests"
        direction TB
        TestProject["Tests Project"]:::test
        TestFixtures["Test Fixtures & Helpers"]:::test
        TestCases["Test Cases"]:::test
        TestProject --> TestFixtures
        TestProject --> TestCases
    end

    %% Relationships
    ConsumerApp -->|"loads views, invokes MarkupExtension"| WPFRuntime
    WPFRuntime -->|"resolve MarkupExtension"| XamlModule
    ConsumerApp -->|"Subscribe to INotifyPropertyChanged"| BindingModule
    ConsumerApp -->|"Use RelayCommand, DI, Logging"| InfraModule
    XamlModule -->|"uses utilities"| InfraModule
    BindingModule -->|"uses utilities"| InfraModule
    TestProject -.->|"validate reactivity behaviors"| BindingModule

    %% Click Events for component mapping
    click XamlModule "https://github.com/dingpingzhang/wpfextensions/tree/master/WpfExtensions.Xaml/"
    click Converters "https://github.com/dingpingzhang/wpfextensions/tree/master/WpfExtensions.Xaml/Converters/"
    click ExtensionMethodsXaml "https://github.com/dingpingzhang/wpfextensions/tree/master/WpfExtensions.Xaml/ExtensionMethods/"
    click Markup "https://github.com/dingpingzhang/wpfextensions/tree/master/WpfExtensions.Xaml/Markup/"
    click I18nManager "https://github.com/dingpingzhang/wpfextensions/blob/master/WpfExtensions.Xaml/I18nManager.cs"
    click I18nSource "https://github.com/dingpingzhang/wpfextensions/blob/master/WpfExtensions.Xaml/I18nSource.cs"
    click BindingModule "https://github.com/dingpingzhang/wpfextensions/tree/master/WpfExtensions.Binding/"
    click CoreReactivity "https://github.com/dingpingzhang/wpfextensions/blob/master/WpfExtensions.Binding/Reactivity.cs"
    click CoreReactivity "https://github.com/dingpingzhang/wpfextensions/blob/master/WpfExtensions.Binding/IReactivity.cs"
    click ASTNodes "https://github.com/dingpingzhang/wpfextensions/blob/master/WpfExtensions.Binding/ConditionalNode.cs"
    click ASTNodes "https://github.com/dingpingzhang/wpfextensions/blob/master/WpfExtensions.Binding/DeepNode.cs"
    click BindingExt "https://github.com/dingpingzhang/wpfextensions/blob/master/WpfExtensions.Binding/Extensions.cs"
    click InfraModule "https://github.com/dingpingzhang/wpfextensions/tree/master/WpfExtensions.Infrastructure/"
    click Commands "https://github.com/dingpingzhang/wpfextensions/tree/master/WpfExtensions.Infrastructure/Commands/"
    click ExtInfra "https://github.com/dingpingzhang/wpfextensions/tree/master/WpfExtensions.Infrastructure/Extensions/"
    click MvvmHelpers "https://github.com/dingpingzhang/wpfextensions/tree/master/WpfExtensions.Infrastructure/Mvvm/"
    click Utilities "https://github.com/dingpingzhang/wpfextensions/blob/master/WpfExtensions.Infrastructure/IContainerProvider.cs"
    click TestProject "https://github.com/dingpingzhang/wpfextensions/blob/master/Tests/Tests.csproj"
    click TestFixtures "https://github.com/dingpingzhang/wpfextensions/blob/master/Tests/Binding/ITestObject.cs"
    click TestCases "https://github.com/dingpingzhang/wpfextensions/blob/master/Tests/Binding/Tests.cs"

    %% Styles
    classDef xaml fill:#e0ffe0,stroke:#098700;
    classDef binding fill:#e0f0ff,stroke:#0047b3;
    classDef infra fill:#fff0e0,stroke:#ff8000;
    classDef runtime fill:#f0f0f0,stroke:#666;
    classDef external fill:#ddd,stroke:#999;
    classDef test fill:#ffe0f0,stroke:#b30000,stroke-dasharray:5 5;
```
