You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/mvvm/MigratingFromMvvmLight.md
+86-1Lines changed: 86 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -309,6 +309,81 @@ var isInDesignMode = ViewModelBase.IsInDesignModeStatic;
309
309
// No direct replacement, remove
310
310
```
311
311
312
+
## Migrating RelayCommand
313
+
314
+
The following steps focus on migrating your existing components which take advantage of the `RelayCommand` of the MvvmLight Toolkit.
315
+
316
+
The Windows Community Toolkit MVVM framework provides a [`RelayCommand`](RelayCommand) type that provides like-for-like functionality taking advantage of the `ICommand` System interface.
317
+
318
+
Below are a list of migrations that will need to be performed if being used in your current solution. Where a method or property isn't listed, there is a direct replacement with the same name in the MVVM Toolkit and there is no change required.
319
+
320
+
The first change here will be swapping using directives in your components.
321
+
322
+
```csharp
323
+
// MvvmLight
324
+
usingGalaSoft.MvvmLight.Command;
325
+
usingGalasoft.MvvmLight.CommandWpf;
326
+
327
+
// Toolkit.Mvvm
328
+
usingMicrosoft.Toolkit.Mvvm.Input;
329
+
```
330
+
331
+
**Note** on `RelayCommand` constructors. MvvmLight uses weak references to establish the link between the command and the action called from the associated class. This is not required by the MVVM Toolkit implementation and if this optional parameter has been set to `true` in any of your constructors, this will be removed.
332
+
333
+
### RelayCommand Methods
334
+
335
+
#### RaiseCanExecuteChanged ()
336
+
337
+
The functionality of `RaiseCanExecuteChanged()` can be achieved with the MVVM Toolkit's `NotifyCanExecuteChanged()` method.
338
+
339
+
340
+
```csharp
341
+
// MvvmLight
342
+
varcommand=newRelayCommand(this.OnCommand);
343
+
command.RaiseCanExecuteChanged();
344
+
345
+
// Toolkit.Mvvm
346
+
varcommand=newRelayCommand(this.OnCommand);
347
+
command.NotifyCanExecuteChanged();
348
+
```
349
+
350
+
## Migrating RelayCommand<T>
351
+
352
+
The following steps focus on migrating your existing components which take advantage of the `RelayCommand<T>` of the MvvmLight Toolkit.
353
+
354
+
The Windows Community Toolkit MVVM framework provides a [`RelayCommand<T>`](RelayCommand) type that provides like-for-like functionality taking advantage of the `ICommand` System interface.
355
+
356
+
Below are a list of migrations that will need to be performed if being used in your current solution. Where a method or property isn't listed, there is a direct replacement with the same name in the MVVM Toolkit and there is no change required.
357
+
358
+
The first change here will be swapping using directives in your components.
359
+
360
+
```csharp
361
+
// MvvmLight
362
+
usingGalaSoft.MvvmLight.Command;
363
+
usingGalasoft.MvvmLight.CommandWpf;
364
+
365
+
// Toolkit.Mvvm
366
+
usingMicrosoft.Toolkit.Mvvm.Input;
367
+
```
368
+
369
+
**Note** on `RelayCommand<T>` constructors. MvvmLight uses weak references to establish the link between the command and the action called from the associated class. This is not required by the MVVM Toolkit implementation and if this optional parameter has been set to `true` in any of your constructors, this will be removed.
370
+
371
+
### RelayCommand<T> Methods
372
+
373
+
#### RaiseCanExecuteChanged ()
374
+
375
+
The functionality of `RaiseCanExecuteChanged()` can be achieved with the MVVM Toolkit's `NotifyCanExecuteChanged()` method.
The [IoC](Ioc) implementation in the MVVM Toolkit takes advantage of existing .NET APIs through the `Microsoft.Extensions.DependencyInjection` library.
@@ -420,6 +495,16 @@ A note on `Register` methods throughout this migration. MvvmLight uses weak refe
420
495
421
496
Below are a list of migrations that will need to be performed if being used in your current solution.
422
497
498
+
The first change here will be swapping using directives in your components.
0 commit comments