What is ObservableCollection and why use it for lists?
ObservableCollection implements INotifyCollectionChanged, so adding/removing items automatically updates a bound CollectionView without rebinding. Use it for dynamic lists.
The 50 .NET MAUI questions worth preparing first, picked from all 200 on W3Teacher and spread across 31 topics. Each one has a short answer here and a full answer with examples and follow-ups on its own page.
ObservableCollection implements INotifyCollectionChanged, so adding/removing items automatically updates a bound CollectionView without rebinding. Use it for dynamic lists.
OnAppearing runs when a page becomes visible (good for loading/refreshing data and subscribing to events) and OnDisappearing when it's navigated away (good for saving state and unsubscribing).
Use MVVM with compiled bindings, keep logic in testable view models/services, use DI instead of service location, centralize styles/resources, prefer CollectionView and shallow templates, handle async correctly, and isolate platform code behind interfaces.
Each platform has a single main/UI thread that owns the visual tree; touching UI from another thread causes exceptions or corruption.
Label displays read-only text. Entry is a single-line editable text box (with keyboard, placeholder, IsPassword options). Editor is a multi-line editable text area that grows or scrolls. Choose Entry for names or search boxes and Editor for comments or descriptions.
Data binding connects a target property on a UI element to a source property on another object (usually a view model), so changes propagate automatically. You set BindingContext and use {Binding Path}. Bindings can be OneWay, TwoWay, or OneTime, reducing manual UI-update code.
MAUI uses Microsoft.Extensions.DependencyInjection through the Generic Host. Register services on builder.Services in MauiProgram.CreateMauiApp, then constructor-inject them into pages and view models. The container resolves the whole graph when a registered page is created.
MAUI runs on Windows via WinUI 3 (Windows App SDK) and on macOS via Mac Catalyst (running the iOS UIKit stack on the Mac). One codebase produces desktop apps alongside mobile, though desktop adds concerns like resizable windows, menus, and pointer/keyboard input.
Use Geolocation.Default.GetLocationAsync (last-known or a fresh request with GeolocationRequest specifying accuracy and timeout). Request location permission first. GetLastKnownLocationAsync is faster but may be stale; GetLocationAsync forces a fix.
Place the .ttf/.otf in Resources/Fonts (MauiFont build action), register it with an alias in ConfigureFonts, then reference the alias via FontFamily. This works consistently across platforms without per-platform font registration.
Compose Entry, Editor, Picker, DatePicker, TimePicker, Switch, and Stepper controls in a layout, bind each to view-model properties (two-way), and bind a submit Button to a command. Set keyboard types and placeholders to guide input.
.NET Multi-platform App UI (.NET MAUI) is Microsoft's cross-platform framework for building native mobile and desktop apps from a single C# and XAML codebase.
Add a TapGestureRecognizer to a view's GestureRecognizers and bind its Command (or handle Tapped). This lets non-button elements like images or labels respond to taps, and NumberOfTapsRequired supports double-tap.
GraphicsView is a canvas for 2D drawing via an IDrawable. You implement Draw(ICanvas canvas, RectF dirtyRect) to render shapes, paths, text, and images with platform-consistent output.
Preferences stores small key-value primitives (strings, numbers, booleans, dates) in platform-native settings storage. Use it for lightweight, non-sensitive app state like the last-selected tab, a theme choice, or a first-run flag. It is not for large or structured data.
Add the Microsoft.Maui.Controls.Maps package, initialize it with UseMauiMaps() in MauiProgram, and place a Map control. It uses the native map on each platform (Apple Maps, Google Maps, Bing/Windows). Set MapType and the visible region.
Create a new MAUI project (or use the .NET Upgrade Assistant), move shared code and XAML in, consolidate the platform head projects into the single project's Platforms folders, update NuGet packages to MAUI-compatible versions, replace custom renderers with handlers, and fix…
Add it like any .NET package (dotnet add package or the IDE), ensuring the package supports the MAUI target frameworks. Cross-platform packages 'just work'; platform-specific ones may only apply to certain TFMs. Check for MAUI compatibility before adopting a library.
Use HttpClient (ideally via IHttpClientFactory) to send async requests, and System.Text.Json to deserialize responses. Always await calls off the UI thread and handle non-success status codes. Set base address and default headers once on the client.
Use CollectionView (virtualized) over ListView; keep item templates shallow; enable compiled bindings with x:DataType; avoid nested layouts inside cells; and size images appropriately. Flat, simple templates recycle faster and scroll more smoothly.
Use conditional compilation with platform symbols (ANDROID, IOS, MACCATALYST, WINDOWS) inside shared code, or split logic into files under Platforms/ that compile only for their target.
The Platforms folder holds platform-specific entry points and code: Android (MainActivity, MainApplication), iOS/MacCatalyst (AppDelegate, Program), and Windows (App.xaml).
Build with the Release configuration for the target framework, which enables optimizations, trimming, and (on iOS) AOT. Use dotnet publish -f -c Release to produce the platform artifact (APK/AAB, IPA, MSIX, or app bundle). Configure signing before publishing.
Use SecureStorage, which encrypts values with the platform keystore/keychain, for tokens and secrets. Never keep them in Preferences (plain) or in source. Clear tokens on logout with SecureStorage.Default.Remove or RemoveAll.
Shell is an app container that provides a common navigation structure: a flyout menu, bottom tabs, top tabs, and URI-based routing. It reduces boilerplate compared to manually composing NavigationPage and TabbedPage, and centralizes navigation, search handlers, and styling.
A ResourceDictionary stores reusable resources (colors, styles, templates, converters) keyed by x:Key. Define it at app, page, or control scope; reference resources with StaticResource (resolved once) or DynamicResource (tracks changes).
Put testable logic in view models and services (plain .NET classes), then test them with xUnit/NUnit/MSTest in a separate class-library targeting a plain TFM (e.g., net8.0).
Usually the BindingContext is null/wrong, the path has a typo, or the source doesn't raise PropertyChanged. Enable binding diagnostics/debug output, add x:DataType for compile-time checking, verify BindingContext, and confirm the property raises change notification.
Markup extensions provide values to XAML attributes at parse time using {} syntax, e.g., {Binding}, {StaticResource}, {DynamicResource}, {x:Static}, {OnPlatform}, {OnIdiom}. They let you reference resources, bind data, or compute values declaratively instead of hardcoding.
XAML (eXtensible Application Markup Language) is a declarative XML-based language for defining UI. In MAUI each page or view typically has a .xaml file for layout and a .xaml.cs code-behind. XAML elements map to C# objects, so is equivalent to new Label { Text = "Hi" }.
Use CollectionView, MAUI's performant, virtualized list control. Bind ItemsSource to a collection and define an ItemTemplate with a DataTemplate. CollectionView supports linear and grid layouts, grouping, selection modes, and empty views, and replaces the older, heavier ListView.
MVVM (Model-View-ViewModel) separates the UI (View) from presentation logic (ViewModel) and data (Model). The View binds to the ViewModel, which exposes properties and commands.
Singleton creates one instance for the app's lifetime—good for shared state, HTTP clients, and caches. Transient creates a new instance per resolution—good for view models and lightweight services. Scoped is per-scope (used more in Blazor Hybrid).
Use MediaPicker.Default.PickPhotoAsync to choose from the gallery or CapturePhotoAsync to use the camera (camera requires permission and hardware). Both return a FileResult you can open as a stream to display or upload.
Register the icon font (e.g., FontAwesome/Material Icons), then set a Label or button ImageSource to a FontImageSource specifying the glyph unicode and FontFamily. This gives crisp, scalable, tintable icons without image assets.
Bind Picker.ItemsSource to a collection and SelectedItem (or SelectedIndex) to a view-model property; set ItemDisplayBinding to show a property of complex items. Picker presents a native selection UI on each platform.
MAUI is the successor to Xamarin.Forms. Key differences: MAUI uses a single project with multi-targeting instead of one project per platform; it uses a new handler-based architecture instead of renderers; it ships as part of the .NET SDK workload rather than a NuGet package; and…
MAUI includes TapGestureRecognizer, PanGestureRecognizer (drag), PinchGestureRecognizer (zoom), SwipeGestureRecognizer (directional swipes), and DragGestureRecognizer/DropGestureRecognizer (drag-and-drop). Multiple recognizers can be attached to one view.
SecureStorage saves key-value string data encrypted using platform keystores (Android Keystore, iOS Keychain). Use it for sensitive values—auth tokens, refresh tokens, API keys tied to a user. It's asynchronous and should not hold large blobs.
Blazor Hybrid hosts Blazor (Razor) components in a BlazorWebView inside a native MAUI app, running .NET locally (not on a server) with full native API access. Use it to reuse web UI/components across web and native, or when your team prefers HTML/CSS.
The MAUI Community Toolkit is a package of behaviors, converters, animations, views (e.g., popups, MediaElement, DrawingView, Expander), and helpers that fill gaps in the core framework.
Use dot paths like {Binding Order.Customer.Name}. If intermediate values can be null, bindings resolve to empty rather than throwing, but you can supply FallbackValue and TargetNullValue for clarity. Compiled bindings (x:DataType) validate the path at build time.
The Application creates Windows; each Window raises Created, Activated, Deactivated, Stopped, Resumed, and Destroying. App-level state changes map to the active window's events.
Use feature folders (or layered folders: Views, ViewModels, Services, Models) and consider separate class libraries for domain/core and infrastructure so logic is reusable and testable. Keep the MAUI head focused on UI.
Offload CPU-bound work with Task.Run so it executes on a thread-pool thread, await the result, then update UI on the main thread. Don't use Task.Run for I/O (await the async API directly). Keep the UI responsive by never blocking it with .Result or .Wait().
Use DeviceInfo.Idiom/OnIdiom to branch layout, provide larger hit targets and multi-column layouts on desktop, add menus (MenuBarItems) and keyboard accelerators, and handle window resizing with responsive Grids. Test pointer hover states, which don't exist on touch.
Call Invalidate() on the GraphicsView to request that Draw runs again. Do this whenever the data your drawable depends on changes. For animation, invalidate on a timer or from an animation callback, keeping the Draw method fast to sustain frame rate.
Add Pin objects to Map.Pins with a Location, Label, and Address, and call MoveToRegion with a MapSpan centered on a location and radius. You can handle pin taps via the InfoWindowClicked/MarkerClicked events.
Xamarin.Forms types move to Microsoft.Maui and Microsoft.Maui.Controls. Xamarin.Essentials merges into Microsoft.Maui.* namespaces. Update using directives and XAML namespace declarations (the default xmlns changes to the MAUI schema). Global usings can reduce repetitive imports.
Use a .NET for Android binding library that projects the Java/Kotlin AAR or JAR into C# through a bindings project, then reference it from Platforms/Android code. Microsoft provides binding tooling and metadata transforms to fix API surface issues.
Run a timed .NET MAUI mock interview: random questions, answer out loud, reveal the model answer and get a readiness score you can share.