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/articles/en/Navigation/HowTo-ModelDefinition-en.md
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,10 @@ public partial class DashboardViewModel : ObservableObject
64
64
}
65
65
```
66
66
67
+
With this code, you can bind the `Name` property in the View and use the `NavigateSecondAsyncCommand` to navigate to the `SecondViewModel`.
68
+
69
+
You can use a button or another control in the View to trigger navigation, but by binding the `IsEnabled` property of the control to the `CanExecute` status of the command, you can only execute navigation when the name is not empty.
70
+
67
71
### [Mvux](#tab/mvux)
68
72
69
73
```csharp
@@ -92,8 +96,12 @@ public partial record MainModel
92
96
}
93
97
```
94
98
95
-
With this code, you can bind the `Name` property in the View and use the `NavigateSecondAsyncCommand`to navigate to the `SecondViewModel`.
99
+
Here you can define a button in the View that calls the `NavigateSecondAsync` method to navigate to the `SecondModel`, retrieve the `Name` value, and pass it as data to the next page.
96
100
97
-
You can use a button or another control in the View to trigger navigation, but by binding the `IsEnabled` property of the control to the `CanExecute` status of the command, you can only execute navigation when the name is not empty.
101
+
If you compare how this looks in MVVM and MVUX, you'll notice it's fundamentally quite similar, but in MVUX the whole thing is somehow more organized and you need less "boilerplate" code to achieve the same result.
102
+
103
+
To create a TwoWay binding directly on the `IState<string> Name` in the View, you don't even need a `PropertyChanged` notification like you would in MVVM. Instead, you simply attach a `.ForEach(...)` to the `.Value(...)`, create a method that receives the new value, and you can work with it directly. No more tedious implementation of `INotifyPropertyChanged`.
104
+
105
+
Learn more about this in the [Guide: React to Route Changes](xref:DevTKSS.Uno.ExtensionsNavigation.HowTo-ChangeRoutes.en).
0 commit comments