mansik / MauiApp2

.NET MAUI Data Binding with MVVM & XAML [5 of 8] and Navigation Between Pages[6 of 8]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MauiApp1

About

(Example).NET MAUI for Beginners

.NET MAUI Data Binding with MVVM & XAML [5 of 8] | .NET MAUI for Beginners Navigating Between Pages in .NET MAUI [6 of 8] | .NET MAUI for Beginners

Environment

  • IDE: Visual Studio 2022
  • Language: C#
  • Applied Project Template: .MAUI APP
  • NuGet
    • CommunityToolkit.Mvvm
  • Third Party Libraries: x
  • DataBase: x

Reference

Process

  • install Nuget CommunityToolkit.Mvvm
  • create ViewModel Folder and MainViewModel.cs class
  • MainViewModel.cs:
    • public partial class MainViewModel : ObservableObject
    • add ObservableProperty, RelayCommand
  • MainPage.xaml: add ContentPage and Add Data Binding
    • xmlns:viewmodel="clr-namespace:MauiApp2.ViewModel"
    • x:DataType="viewmodel:MainViewModel"
    • use Data Binding and x:DataType
  • MainPage.xaml.cs: add BindingContext = vm;
  • MauiProgram.cs: Add AddSingleton
    • builder.Services.AddSingleton();
    • builder.Services.AddSingleton();

About

.NET MAUI Data Binding with MVVM & XAML [5 of 8] and Navigation Between Pages[6 of 8]

License:MIT License


Languages

Language:C# 100.0%