Skip to content

Commit 72b4c90

Browse files
committed
docs(ModelDefinition): align English version with german docs
1 parent 88bac48 commit 72b4c90

File tree

2 files changed

+57
-10
lines changed

2 files changed

+57
-10
lines changed

docs/articles/de/Navigation/HowTo-ModelDefinition-de.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Also, dann lass uns das doch mal genauer betrachten. Was bedeutet das denn nun?
2323
In diesem Fall wären es dann nur zum beispiel die anzuzeigende Eigenschaft, wie die `string`-Property `Title`, die du entsprechend in deiner `Page`, also deiner `View` zum `ViewModel` bzw. `Model` bindest und schon bist du fertig damit!
2424

2525
> [!TIP]
26-
> Mit der Attached Property `uen:Navi` kannst du den Titel der Seite in der NavigationView setzen.
26+
> Mit der `Attached Property` `uen:Navigation.Request` bzw. `uen:Navigation.Data` kannst du übrigens auch Daten an die Navigation übergeben, wie [in der Uno Dokumentation gut anhand von `Widget`-Elementen erklärt wird](https://platform.uno/docs/articles/external/uno.extensions/doc/Learn/Navigation/HowTo-NavigateInXAML.html#2-navigationdata) hierfür benötigst du dann bspw. aber wieder `DataViewMap`-Definitionen in der Routen Registrierung.
2727
2828
- **Nein:**
2929

docs/articles/en/Navigation/HowTo-ModelDefinition-en.md

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,70 @@ uid: DevTKSS.Uno.ExtensionsNavigation.HowTo-DefiningModelOrViewModel.en
44

55
# How-To: Navigation in the Model or ViewModel
66

7-
Now let's take a look at how we need to structure our Model or ViewModel to work with Uno Extensions Navigation.
7+
Now let's take a look at how we need to structure the connection between the `View` and the `ViewModel` to work with Uno Extensions Navigation.
88

9-
## Prerequisites
9+
First, let's ask ourselves the question: **Navigation only in Xaml - Is that even possible?**
10+
11+
*Yes and No.*
12+
13+
So, let's take a closer look. What does this mean?
14+
15+
- **Yes:**
16+
17+
In fact, you basically don't need either codebehind or code in the ViewModel / Model for navigation if you use the `Attached Properties` in the Xaml of your page.
18+
19+
**If you're interested in how this works, you can find it directly here:**
20+
21+
[How-To: Defining the UI with NavigationView for ExtensionsNavigation](xref:DevTKSS.Uno.ExtensionsNavigation.HowTo-Defining-UI.en)
22+
23+
In this case, it would typically only be the properties to display, like the `string` property `Title`, that you bind from your `Page`, i.e., your `View` to the `ViewModel` or `Model`, and you're done!
24+
25+
> [!TIP]
26+
> By the way, with the `Attached Properties` `uen:Navigation.Request` and `uen:Navigation.Data` you can also pass data to navigation, as [explained well in the Uno documentation using `Widget` elements as examples](https://platform.uno/docs/articles/external/uno.extensions/doc/Learn/Navigation/HowTo-NavigateInXAML.html#2-navigationdata). However, for this you'll need `DataViewMap` definitions in the route registration.
1027
11-
1. First of all, create a Model or ViewModel element.
28+
- **No:**
1229

13-
[!INCLUDE [Guide to creating a basic Model or ViewModel](../HowTo-Adding-New-VM-Class-Record-en.md)]
30+
1. You still need to register the routes you want to navigate in the `RegisterRoutes` method in the `App.xaml.cs` class, so the `INavigator` knows what belongs together and from where you want to allow navigation to which routes with which "qualifiers".
31+
2. If you want to trigger navigation in your Model or ViewModel, then of course you need the `INavigator` there to start the navigation.
1432

15-
2. Now add the `INavigator` as a **DependencyInjection** constructor parameter.
33+
## Creating the Prerequisites
1634

17-
[!INCLUDE [Guide: Use Constructor Parameters for DependencyInjection](../HowTo-Using-DI-in-ctor-en.md)]
35+
Okay, so let's assume we have the second case mentioned above and want to do the following:
1836

19-
## Navigation in Xaml
37+
1. Our user should be able to trigger a function in our `ViewModel` or `Model` by clicking a `Button`
38+
2. This function should navigate them to the `SecondPage` that we included in the Uno App template, but it could also be any other page you created and registered yourself.
39+
40+
Let's assume this is our `App.xaml.cs` with the `RegisterRoutes` method:
41+
42+
```csharp
43+
{
44+
views.Register(
45+
new ViewMap(ViewModel: typeof(ShellModel)),
46+
new ViewMap<MainPage, MainModel>(),
47+
new DataViewMap<SecondPage, SecondViewModel, Entity>()
48+
);
49+
50+
routes.Register(
51+
new RouteMap("", View: views.FindByViewModel<ShellModel>(),
52+
Nested:
53+
[
54+
new RouteMap("Main", View: views.FindByViewModel<MainModel>(), IsDefault:true),
55+
new RouteMap("Second", View: views.FindByViewModel<SecondModel>())
56+
]
57+
)
58+
);
59+
}
60+
```
61+
62+
But how should our `ViewModel` or `Model` look so we can implement this?
63+
64+
For this we need the following steps:
65+
66+
## Prerequisites
2067

21-
Basically, you don't actually need navigation code in the ViewModel / Model if you use the `Attached Properties` as described in the [Guide: Defining the UI with NavigationView for ExtensionsNavigation](xref:DevTKSS.Uno.ExtensionsNavigation.HowTo-Defining-UI.en)!
68+
1. [Create a Model or ViewModel](xref:DevTKSS.Uno.Setup.HowTo-AddingNew-VM-Class-Record.en)
2269

23-
In this case, it would typically only be the Title properties or others that you bind from View to ViewModel and you would be done. And that is also a big advantage of this extension in my opinion.
70+
2. [And get the `INavigator` there as a **`DependencyInjection` Constructor Parameter**](xref:DevTKSS.Uno.Setup.Using-DI-in-ctor.en)
2471

2572
## Binding View UI Controls to Properties in the ViewModel or Model
2673

0 commit comments

Comments
 (0)