Skip to content

Commit 44e1018

Browse files
authored
Merge pull request #2350 from unoplatform/dev/erli/2290-grid-navigator-visibility
docs(NavigationView): Add note regarding Grid for navigation
2 parents ab95e46 + f065fb6 commit 44e1018

File tree

1 file changed

+29
-42
lines changed

1 file changed

+29
-42
lines changed

doc/Learn/Navigation/Advanced/HowTo-UseNavigationView.md

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,10 @@ Choosing the right control for your navigation needs is important, and one commo
2828
</Grid>
2929
```
3030

31-
* Add a `RowDefinition` to the `Grid`'s `RowDefinitions` collection. This will define the height of the `NavigationView`'s menu.
32-
33-
```xml
34-
<Grid.RowDefinitions>
35-
<RowDefinition Height="Auto" />
36-
<RowDefinition />
37-
</Grid.RowDefinitions>
38-
```
39-
4031
* Add a `NavigationView` control to the `Grid`. This will be the menu for the app.
4132

4233
```xml
43-
<NavigationView Grid.Row="1">
34+
<NavigationView>
4435
...
4536
</NavigationView>
4637
```
@@ -53,7 +44,7 @@ Choosing the right control for your navigation needs is important, and one commo
5344
For this tutorial, `Grid` should be placed in the `Content` area.
5445

5546
```xml
56-
<Grid Grid.Row="1">
47+
<Grid>
5748
...
5849
</Grid>
5950
```
@@ -75,24 +66,24 @@ Choosing the right control for your navigation needs is important, and one commo
7566
* Inside the `Grid` element of the `NavigationView`, add a `Grid` element to represent the content of each view you can to navigate to.
7667

7768
```xml
78-
<Grid Grid.Row="1">
69+
<Grid>
7970
<Grid>
8071
<TextBlock Text="One"
81-
FontSize="24"
82-
HorizontalAlignment="Center"
83-
VerticalAlignment="Center" />
72+
FontSize="24"
73+
HorizontalAlignment="Center"
74+
VerticalAlignment="Center" />
8475
</Grid>
8576
<Grid>
8677
<TextBlock Text="Two"
87-
FontSize="24"
88-
HorizontalAlignment="Center"
89-
VerticalAlignment="Center" />
78+
FontSize="24"
79+
HorizontalAlignment="Center"
80+
VerticalAlignment="Center" />
9081
</Grid>
9182
<Grid>
9283
<TextBlock Text="Three"
93-
FontSize="24"
94-
HorizontalAlignment="Center"
95-
VerticalAlignment="Center" />
84+
FontSize="24"
85+
HorizontalAlignment="Center"
86+
VerticalAlignment="Center" />
9687
</Grid>
9788
</Grid>
9889
```
@@ -103,7 +94,7 @@ Choosing the right control for your navigation needs is important, and one commo
10394

10495
* Add the `uen:Region.Attached` attached property to each of the following elements:
10596

106-
* The `Grid` element that contains the `NavigationView` and the `Grid` element that contains the content area.
97+
* The `Grid` element that contains the `NavigationView`.
10798
* The `NavigationView` element.
10899
* The `Grid` element that contains the content area.
109100

@@ -135,6 +126,9 @@ Choosing the right control for your navigation needs is important, and one commo
135126
uen:Region.Navigator="Visibility"
136127
```
137128

129+
> [!IMPORTANT]
130+
> Even if you're not utilizing the `<Grid>` element to arrange the content (ie, you're navigating between pages defined with routes), you must still include the `<Grid>` element with the `uen:Region.Navigator="Visibility"` and `uen:Region.Attached="True"` attached properties. These properties are essential for enabling the navigator functionality.
131+
138132
* Add the `uen:Region.Name` attached property to each of the `Grid` elements that contain the content area. This will define the name of the view that the `Grid` will represent.
139133

140134
```xml
@@ -180,21 +174,20 @@ Choosing the right control for your navigation needs is important, and one commo
180174
* Add a new **Page** item to your app called `ProductsPage` with the following code:
181175

182176
```xml
183-
<Page
184-
x:Class="UsingNavigationView.Views.ProductsPage"
185-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
186-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
187-
xmlns:local="using:Uno.Extensions.Navigation.UI.Samples"
188-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
189-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
190-
mc:Ignorable="d"
191-
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
177+
<Page x:Class="UsingNavigationView.Views.ProductsPage"
178+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
179+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
180+
xmlns:local="using:Uno.Extensions.Navigation.UI.Samples"
181+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
182+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
183+
mc:Ignorable="d"
184+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
192185

193186
<Grid>
194187
<TextBlock Text="Products"
195-
FontSize="24"
196-
HorizontalAlignment="Center"
197-
VerticalAlignment="Center" />
188+
FontSize="24"
189+
HorizontalAlignment="Center"
190+
VerticalAlignment="Center" />
198191
</Grid>
199192
</Page>
200193
```
@@ -278,13 +271,8 @@ Choosing the right control for your navigation needs is important, and one commo
278271
Background="{ThemeResource MaterialBackgroundBrush}">
279272

280273
<Grid uen:Region.Attached="True">
281-
<Grid.RowDefinitions>
282-
<RowDefinition Height="Auto" />
283-
<RowDefinition />
284-
</Grid.RowDefinitions>
285274

286-
<NavigationView uen:Region.Attached="true"
287-
Grid.Row="1">
275+
<NavigationView uen:Region.Attached="true">
288276
<NavigationView.MenuItems>
289277
<NavigationViewItem Content="One"
290278
uen:Region.Name="One" />
@@ -297,8 +285,7 @@ Choosing the right control for your navigation needs is important, and one commo
297285
</NavigationView.MenuItems>
298286

299287
<Grid uen:Region.Attached="True"
300-
uen:Region.Navigator="Visibility"
301-
Grid.Row="1">
288+
uen:Region.Navigator="Visibility">
302289
<Grid uen:Region.Name="One"
303290
Visibility="Collapsed">
304291
<TextBlock Text="One"

0 commit comments

Comments
 (0)