.Net Maui – ContentView with a ViewModel – Maui

by
Ali Hasan
c# data-binding maui xaml

The Problem:

.Net Maui – ContentView with a ViewModel: unable to update UI from changes in the view model. Why is the data binding not working as expected in this scenario?

Q&A

What I can tell from your code you set the Label from the View and not from the ViewModel and to be frank you should not have the ContentView communicating with the ViewModel. It should be resuable.

The View communicate with the ViewModel and with the control.

Based on your code, I achieved this function, you can refer to the following code:

Update the value of the ContentView by binding to a property in a ViewModel and handle a Command in the ViewModel to update the property.

Video Explanation:

The following video, titled "”.NET", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

This video provides further insights and detailed explanations related to the content discussed in the article.

| .NET MAUI for …” description=”… NET MAUI for iOS, Android, macOS, and Windows from a shared C# code base. In this video, James introduces us to the MVVM (Model-View-ViewModel) …”]