Posts

Showing posts with the label MVVM

5 Modern Alternatives to MessagingCenter in .NET MAUI 9

Image
Join our exclusive WhatsApp group for Xamarin and .NET MAUI developers to connect with experts, share insights, and get help with your projects. Whether you're a beginner or an experienced developer, this group is the perfect place to enhance your skills and collaborate with the community. Sending Messages in .NET MAUI 9 — Modern Alternatives to MessagingCenter Short summary: MessagingCenter was handy in Xamarin.Forms for broadcast-style communication across pages/viewmodels/services. In .NET MAUI (.NET 9) you should use modern, safer, and more testable approaches. This post covers five alternatives. For each option we’ll walk step-by-step: diagram → code (string & class) → detailed explanation. 1. WeakReferenceMessenger (CommunityToolkit.Mvvm) — Recommended Sender → Messenger → Receiver (weak references used by messenger) String Message Example // Send WeakReferenceMessenger.Default.Send("Hello from Page A"); // Receive WeakReferenceMessenger....

Nested Template Using MVVM - Xamarin Form

Image
Nested Template MVVM - Xamarin Form Code is explain in this video SkillTemplate.xaml <ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:vm="clr-namespace:MVVMDemo.ViewModels" x:Class="MVVMDemo.Views.ListTemplate.SkillTemplate"> <ContentView.Content> <StackLayout x:DataType="vm:TechnicalSkill" Padding="0,10"> <Label Text="{Binding Name}" TextColor="Black"/> </StackLayout> </ContentView.Content> </ContentView> EducationTemplate.xaml <ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:vm="clr-namespace:MVVMDemo.ViewModels" x:Class="MVVMDemo.Views.ListTemplate.EducationTemplate...

Login Page - MVVM in xamarin Form

Image
Mvvm in xamarin forms There are three core components in the MVVM pattern: the model, the view, and the view model. For more info please refer this microsoft  link . Code is explain in this video We will see mvvm for Login First we will create BaseViewModel.cs BaseViewModel.cs public class BaseViewModel : INotifyPropertyChanged { // public IDataStore<Item> DataStore => DependencyService.Get<IDataStore<Item>>(); bool isBusy = false; public bool IsBusy { get { return isBusy; } set { SetProperty(ref isBusy, value); } } string title = string.Empty; public string Title { get { return title; } set { SetProperty(ref title, value); } } protected bool SetProperty<T>(ref T backingStore, T value, [CallerMemberName] string propertyName = "", Action onChanged = null) { if (Equ...