Skip to content

Commit

Permalink
docs: clarify xaml-mvvm tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
generousllama541 authored Nov 3, 2024
1 parent df20ef5 commit 325f571
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Also, for more information on all the template options, see [Using the Uno Platf

Now that we have the **`MainViewModel`** class, we can update the **`MainPage`** to use data binding to connect the UI to the application logic.

- Add a **`DataContext`** element to the **`Page`** element in the **MainPage.xaml** file.
- Add a **`DataContext`** element to the **`Page`** element in the **MainPage.xaml** file, between the first `StackPanel` and the `Page` element.

```xml
<Page.DataContext>
Expand Down Expand Up @@ -119,7 +119,7 @@ Now that we have the **`MainViewModel`** class, we can update the **`MainPage`**
TextAlignment="Center" />
```

- Update the **`Button`** to add a **`Command`** attribute that is bound to the **`IncrementCommand`** property of the **`MainViewModel`**.
- Add a new **`Button`** with a **`Command`** attribute that is bound to the **`IncrementCommand`** property of the **`MainViewModel`**.

```xml
<Button Margin="12"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The layout for the **MainPage** is defined in the **MainPage.xaml** file. This file contains the XAML markup that defines the layout of the application.
The layout for the **MainPage** is defined in the **MainPage.xaml** file. This file contains the XAML markup that defines the layout of the application. Replace your **MainPage.xaml** with the contents below:

```xml
<Page x:Class="Counter.MainPage"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ As part of creating the application, we selected MVVM as the presentation framew
private void Increment()
=> Count += Step;
```
> [!NOTE]
> If you see red squiggles under `Count` or `Step`, save the file to have Hot Reload apply your changes.

The final code for the `MainViewModel` class should look like this:

Expand Down

0 comments on commit 325f571

Please sign in to comment.