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/de/Navigation/HowTo-ModelDefinition-de.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ Also, dann lass uns das doch mal genauer betrachten. Was bedeutet das denn nun?
23
23
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!
24
24
25
25
> [!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.
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.
8
8
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.
10
27
11
-
1. First of all, create a Model or ViewModel element.
28
+
-**No:**
12
29
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.
14
32
15
-
2. Now add the `INavigator` as a **DependencyInjection** constructor parameter.
33
+
## Creating the Prerequisites
16
34
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:
18
36
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:
Buthowshouldour `ViewModel` or `Model` looksowecanimplementthis?
63
+
64
+
Forthisweneedthefollowingsteps:
65
+
66
+
## Prerequisites
20
67
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)!
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.
0 commit comments