Skip to content

Commit

Permalink
Replace MS Toolkit with Community Toolkit
Browse files Browse the repository at this point in the history
  • Loading branch information
pomianowski committed Aug 13, 2022
1 parent a2857ac commit bbaebb8
Show file tree
Hide file tree
Showing 29 changed files with 50 additions and 44 deletions.
18 changes: 12 additions & 6 deletions docs/SERVICES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Services
**WPF UI** tries to support ***Dependency Injection*** (DI) and ***Model-View-ViewModel*** (MVVM) patterns.
If you use [CommunityToolkit](https://github.com/CommunityToolkit/dotnet) or [Microsoft.Toolkit.Mvvm](https://docs.microsoft.com/en-us/windows/communitytoolkit/mvvm/introduction) in your application, the services listed below may be useful for you.

**WPF UI** tries to support **_Dependency Injection_** (DI) and **_Model-View-ViewModel_** (MVVM) patterns.
If you use [CommunityToolkit](https://github.com/CommunityToolkit/dotnet) or [CommunityToolkit.Mvvm](https://docs.microsoft.com/en-us/windows/communitytoolkit/mvvm/introduction) in your application, the services listed below may be useful for you.

## Getting started

**MVVM**
Model–view–viewmodel (MVVM) is a software architectural pattern that facilitates the separation of the development of the graphical user interface (the view) – be it via a markup language or GUI code – from the development of the business logic or back-end logic (the model) so that the view is not dependent on any specific model platform.[^1]

Expand All @@ -11,34 +13,41 @@ In software engineering, dependency injection is a design pattern in which an ob

**Sources in WPF UI**
The classes and interfaces created for MVVM and DI are located in the namespace:

```cpp
namespace Wpf.Ui.Mvvm.Services;
```
# DialogService
`DialogService` is responsible for managing the display of the `Dialog` control.
### Contract
```cpp
interface Wpf.Ui.Mvvm.Contracts.IDialogService
```

### Implementation

```cpp
class Wpf.Ui.Mvvm.Services.DialogService
```
## Exposes
```cpp
// Sets the IDialogControl
IDialogService.SetDialogControl(IDialogControl dialog);
```

```cpp
// Provides direct access to the IDialogControl
IDialogService.GetDialogControl();
```

### How to use

```cpp
// Services registration in your service management class
private static void ConfigureServices(HostBuilderContext context, IServiceCollection services)
Expand All @@ -53,8 +62,5 @@ public Container(IDialogService dialogService)
}
```
[^1]: Model–view–viewmodel https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel
[^2]: Dependency injection https://en.wikipedia.org/wiki/Dependency_injection
[^2]: Dependency injection https://en.wikipedia.org/wiki/Dependency_injection
2 changes: 1 addition & 1 deletion src/Packages.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Update="Microsoft.Toolkit.Mvvm" Version="7.1.2"/>
<PackageReference Update="CommunityToolkit.Mvvm" Version="8.0.0"/>
<PackageReference Update="Microsoft.Extensions.Hosting" Version="6.0.1"/>
<PackageReference Update="System.Drawing.Common" Version="6.0.0" />
<PackageReference Update="System.ValueTuple" Version="4.5.0" />
Expand Down
4 changes: 2 additions & 2 deletions src/Wpf.Ui.Demo/ViewModels/ButtonsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// All Rights Reserved.

using System.Windows.Input;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Wpf.Ui.Mvvm.Contracts;

namespace Wpf.Ui.Demo.ViewModels;
Expand Down
4 changes: 2 additions & 2 deletions src/Wpf.Ui.Demo/ViewModels/ColorsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Wpf.Ui.Appearance;
using Wpf.Ui.Common.Interfaces;
using Wpf.Ui.Demo.Models.Colors;
Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui.Demo/ViewModels/ContainerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.

using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;

namespace Wpf.Ui.Demo.ViewModels;

Expand Down
4 changes: 2 additions & 2 deletions src/Wpf.Ui.Demo/ViewModels/DashboardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// All Rights Reserved.

using System.Windows.Input;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Wpf.Ui.Common.Interfaces;
using Wpf.Ui.Demo.Services.Contracts;
using Wpf.Ui.Mvvm.Contracts;
Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui.Demo/ViewModels/DataViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System;
using System.Collections.Generic;
using System.Windows.Media;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using Wpf.Ui.Common.Interfaces;
using Wpf.Ui.Demo.Models.Data;

Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui.Demo/ViewModels/DebugViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// All Rights Reserved.

using System.Collections.Generic;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using Wpf.Ui.Common.Interfaces;

namespace Wpf.Ui.Demo.ViewModels;
Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui.Demo/ViewModels/ExperimentalViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// All Rights Reserved.

using System;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using Wpf.Ui.Common.Interfaces;
using Wpf.Ui.Mvvm.Contracts;

Expand Down
4 changes: 2 additions & 2 deletions src/Wpf.Ui.Demo/ViewModels/IconsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Wpf.Ui.Common.Interfaces;
using Wpf.Ui.Demo.Models.Icons;

Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui.Demo/ViewModels/InputViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// All Rights Reserved.

using System.Collections.Generic;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using Wpf.Ui.Common.Interfaces;

namespace Wpf.Ui.Demo.ViewModels;
Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui.Demo/ViewModels/TaskManagerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// All Rights Reserved.

using System.Collections.ObjectModel;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using Wpf.Ui.Common;
using Wpf.Ui.Controls;
using Wpf.Ui.Controls.Interfaces;
Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui.Demo/Views/Pages/Input.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
Grid.Column="2"
Margin="0,0,0,8"
Content="ThreeState CheckBox"
IsChecked="True"
IsChecked="{x:Null}"
IsThreeState="True" />
<CheckBox
Grid.Column="3"
Expand Down
2 changes: 1 addition & 1 deletion src/Wpf.Ui.Demo/Wpf.Ui.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" />
<PackageReference Include="CommunityToolkit.Mvvm" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.ObjectModel;
using Wpf.Ui.Common;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Wpf.Ui.Common.Interfaces;

namespace $safeprojectname$.ViewModels
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Windows.Media;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Windows.Input;
using Wpf.Ui.Common.Interfaces;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ItemGroup>
<PackageReference Include="WPF-UI" Version="2.0.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.ObjectModel;
using Wpf.Ui.Common;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Wpf.Ui.Common.Interfaces;

namespace $safeprojectname$.ViewModels
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Windows.Media;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Windows.Input;
using Wpf.Ui.Common.Interfaces;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ItemGroup>
<PackageReference Include="WPF-UI" Version="2.0.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.ObjectModel;
using Wpf.Ui.Common;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Wpf.Ui.Common.Interfaces;

namespace $safeprojectname$.ViewModels
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Windows.Media;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Windows.Input;
using Wpf.Ui.Common.Interfaces;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ItemGroup>
<PackageReference Include="WPF-UI" Version="2.0.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0"/>
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit bbaebb8

Please sign in to comment.