diff --git a/MvvmMicro.sln.DotSettings b/MvvmMicro.sln.DotSettings
index 6ff841c..f9fdce5 100644
--- a/MvvmMicro.sln.DotSettings
+++ b/MvvmMicro.sln.DotSettings
@@ -4,6 +4,7 @@
True
True
True
+ True
True
True
True
diff --git a/README.md b/README.md
index 2cd0dd2..ebffc19 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,39 @@
# MvvmMicro
-A clean and lightweight MVVM framework for WPF, UWP and .NET Standard 2.0 inspired by MVVM Light Toolkit.
+A lightweight MVVM framework for .NET inspired by [MVVM Light Toolkit](https://github.com/lbugnion/mvvmlight).
## Goals
+
- No third party dependencies, such as `CommonServiceLocator` or `System.Windows.Interactivity`.
-- Avoid [feature kreep](https://en.wikipedia.org/wiki/Feature_creep) – only core MVVM types and services are included, such as `RelayCommand`, `AsyncRelayCommand`, `ObservableObject` and a simple `IMessenger`.
+- No feature kreep – only core MVVM types and services are included, such as `RelayCommand`, `AsyncRelayCommand`,
+`ObservableObject`, and a simple `IMessenger`.
## Supported platforms
+
- .NET Framework 4.6.2 & .NET 5.0 (WPF)
- Universal Windows Platform (UWP)
-- .NET Standard 2.0
+- .NET Standard 2.0 (Xamarin.Forms, Avalonia, MAUI, etc.)
## Installation
+
The primary way to use MvvmMicro is by adding the [nuget](https://www.nuget.org/packages/MvvmMicro) package to your project:
```
Install-Package MvvmMicro
```
-## Classes and interfaces
-Here's an overview of classes and interfaces exposed by the library:
+## Overview
+
+| Type | Description |
+| ----- | ----------- |
+| ObservableObject | The base class for objects that support property change notification. |
+| ViewModelBase | The base class for view models with the _Messenger_ and _IsInDesignMode_ properties. |
+| Messenger | A service for sending and receiving messages, typically between view models and views. |
+| RelayCommand,
RelayCommand\ | An _ICommand_ implementation based on a synchronous delegate for _Execute_ and _CanExecute_. |
+| AsyncRelayCommand,
AsyncRelayCommand\ | An _ICommand_ implementation based on an asynchronous delegate for _Execute_ with cancellation support. |
+
![Class diagram](src/MvvmMicro/Diagrams/ClassDiagram.png)
+
+## License
+
+Code licensed under the [MIT License](LICENSE).
diff --git a/src/MvvmMicro/Diagrams/ClassDiagram.cd b/src/MvvmMicro/Diagrams/ClassDiagram.cd
index ed0e91a..697c340 100644
--- a/src/MvvmMicro/Diagrams/ClassDiagram.cd
+++ b/src/MvvmMicro/Diagrams/ClassDiagram.cd
@@ -14,13 +14,11 @@
-
+
+
-
-
-
@@ -30,7 +28,7 @@
- AAAAAAAAAAAAAAEAAEAAIAAAAAAiAAAAQAAAAAAAAAA=
+ AAAAAAAQAAAAAAEAAEAAIAAAAAAhAAAAAAAAAAAAEAA=
Messenger.cs
@@ -44,20 +42,24 @@
-
+
+
+
+
+
-
+
- AAAAAAAAABAAAAAAAAQAAAAAAASAAAAAAAAAAAAAAAA=
+ AAAAAAAAAFAAAgAAAgQAAAAAAASAAAQAAAAAAAAAAAA=
ViewModelBase.cs
@@ -68,6 +70,7 @@
+
AAAAAAAAAEAAAAQAAECAAAAAAAAAAAAAAAAAAAAAAAA=
@@ -81,6 +84,7 @@
+
AAAAAAAAAEAAAAQAAECAAAAAAAAAAAAAAAAAAAAAAAA=
@@ -89,10 +93,11 @@
-
+
+
@@ -103,10 +108,11 @@
-
+
+
@@ -119,7 +125,7 @@
-
+
@@ -132,19 +138,19 @@
- AAAAAAAAAAAAAAAAAEAAAAAAAAACAAAAQAAAAAAAAAA=
+ AAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAAAAAAAAEAA=
IMessenger.cs
-
+
AAAAAAAAAAAAAAQAAEAAAAAAAAAAAAAAAAAAAAAAAAA=
ICommand{T}.cs
-
+
AAAAAAAAQAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAEA=
IAsyncCommand.cs
diff --git a/src/MvvmMicro/Diagrams/ClassDiagram.png b/src/MvvmMicro/Diagrams/ClassDiagram.png
index eccb6e2..fcfdd22 100644
--- a/src/MvvmMicro/Diagrams/ClassDiagram.png
+++ b/src/MvvmMicro/Diagrams/ClassDiagram.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:b9714abdfaa474386239dc78931da1907da6d3e77a4f60c067793de880ea44b0
-size 140777
+oid sha256:77eaf1fd3c377acd7aa11fe684090918500fde310b0bc6d3f84e6338ed3c2388
+size 141890
diff --git a/src/MvvmMicro/ViewModelBase.cs b/src/MvvmMicro/ViewModelBase.cs
index 9f28dbb..765b38e 100644
--- a/src/MvvmMicro/ViewModelBase.cs
+++ b/src/MvvmMicro/ViewModelBase.cs
@@ -1,6 +1,7 @@
// Copyright (c) Yaroslav Bugaria. All rights reserved.
using System;
+using System.Reflection;
namespace MvvmMicro;
@@ -26,8 +27,9 @@ public ViewModelBase(IMessenger messenger = null)
///
/// Gets a value indicating whether the application is running in the context of a designer.
///
+ /// true if a designer context was detected; otherwise, false.
///
- /// Supported for WPF and UWP targets only; otherwise, always returns false.
+ /// The following UI frameworks are supported: WPF, UWP, Xamarin.Forms, and Avalonia.
///
public static bool IsInDesignMode => IsInDesignModeLazy.Value;
@@ -37,17 +39,48 @@ public ViewModelBase(IMessenger messenger = null)
protected IMessenger Messenger { get; }
private static bool GetIsInDesignMode()
+ {
+ return GetIsInDesignMode_WPF() ??
+ GetIsInDesignMode_UWP() ??
+ GetIsInDesignMode_XamarinForms() ??
+ GetIsInDesignMode_Avalonia() ??
+ false;
+ }
+
+ private static bool? GetIsInDesignMode_WPF()
{
#if NETFRAMEWORK || NET5_0
- // WPF.
var descriptor = System.ComponentModel.DependencyPropertyDescriptor.FromProperty(
System.ComponentModel.DesignerProperties.IsInDesignModeProperty, typeof(System.Windows.FrameworkElement));
+
return (bool)descriptor.Metadata.DefaultValue;
-#elif WINDOWS_UWP
- // UWP.
+#else
+ return null;
+#endif
+ }
+
+ private static bool? GetIsInDesignMode_UWP()
+ {
+#if WINDOWS_UWP
return Windows.ApplicationModel.DesignMode.DesignModeEnabled;
#else
- return false;
+ return null;
#endif
}
+
+ private static bool? GetIsInDesignMode_XamarinForms()
+ {
+ var design = Type.GetType("Xamarin.Forms.DesignMode, Xamarin.Forms.Core")?.GetProperty(
+ "IsDesignModeEnabled", BindingFlags.Static | BindingFlags.Public)?.GetValue(null);
+
+ return design is bool value ? value : null;
+ }
+
+ private static bool? GetIsInDesignMode_Avalonia()
+ {
+ var design = Type.GetType("Avalonia.Controls.Design, Avalonia.Controls")?.GetProperty(
+ "IsDesignMode", BindingFlags.Static | BindingFlags.Public)?.GetValue(null);
+
+ return design is bool value ? value : null;
+ }
}