Sunday, 3 August 2025

100 MAUI Interview Questions and Answers

 1. Fundamentals (15)

  1. What is .NET MAUI?
    Cross-platform framework for building native mobile (Android/iOS) and desktop (macOS/Windows) apps with C#/XAML.

  2. MAUI vs Xamarin.Forms?
    Single project, improved performance, better Hot Reload, new controls.

  3. Entry point?
    MauiProgram.cs → CreateMauiApp().

  4. Supported OS versions?
    Android 5.0+, iOS 10+, macOS 10.15+, Windows 10+.

  5. What is MauiAppBuilder?
    Configures services/fonts:

    csharp
    var builder = MauiApp.CreateBuilder();
    builder.UseMauiApp<App>();
  6. What is App.xaml?
    Defines global resources and startup page.

  7. How to set startup page?

    csharp
    MainPage = new MainPage();
  8. What is HostBuilder?
    Configures dependency injection and services.

  9. How to use ConfigureEssentials?
    Enables device features (GPS, storage):

    csharp
    builder.ConfigureEssentials(essentials => {...});
  10. What is Blazor Hybrid?
    Embeds Blazor web components in MAUI apps.

  11. How to enable Hot Reload?
    Set EnableHotReload in project file.

  12. What is AOT compilation?
    Ahead-of-Time compilation for better Android performance.

  13. How to check platform?

    csharp
    if (DeviceInfo.Platform == DevicePlatform.Android) {...}
  14. What is IDispatcher?
    Ensures UI updates run on main thread.

  15. How to handle lifecycle events?
    Override OnStartOnSleepOnResume in App.xaml.cs.


2. UI & XAML (25)

  1. How to create a Button?

    xml
    <Button Text="Click" Command="{Binding TapCommand}"/>
  2. What is BindableProperty?
    Enables data binding, styling, and defaults:

    csharp
    public static readonly BindableProperty TextProperty = ...;
  3. How to bind data?

    xml
    <Label Text="{Binding UserName}"/>
  4. What is x:Name?
    Assigns a name to a XAML element for code-behind access.

  5. StaticResource vs DynamicResource?
    StaticResource is fixed; DynamicResource updates dynamically.

  6. How to create a custom control?
    Subclass ContentView + define BindableProperty.

  7. What is ControlTemplate?
    Defines reusable control templates.

  8. How to apply styles?

    xml
    <Style TargetType="Label">
        <Setter Property="TextColor" Value="Red"/>
    </Style>
  9. What is VisualStateManager?
    Manages visual states (e.g., "Pressed", "Disabled").

  10. How to handle dark mode?

    xml
    <Label TextColor="{AppThemeBinding Light=Black, Dark=White}"/>
  11. How to use Grid?

    xml
    <Grid>
        <Label Grid.Row="0" Grid.Column="0" Text="Hello"/>
    </Grid>
  12. What is FlexLayout?
    Responsive layout with flexbox-like behavior.

  13. How to use CollectionView?

    xml
    <CollectionView ItemsSource="{Binding Items}">
        <DataTemplate><Label Text="{Binding Name}"/></DataTemplate>
    </CollectionView>
  14. What is SwipeView?
    Enables swipe gestures on items.

  15. How to use CarouselView?
    Displays items in a carousel.

  16. What is RefreshView?
    Adds pull-to-refresh functionality.

  17. How to create a Picker?

    xml
    <Picker ItemsSource="{Binding Options}" SelectedItem="{Binding SelectedOption}"/>
  18. What is Border?
    Adds borders to any control.

  19. How to use GraphicsView?
    For custom 2D drawings.

  20. What is LazyView?
    Delays loading of heavy UI elements.

  21. How to handle orientation changes?
    Subscribe to DeviceDisplay.MainDisplayInfoChanged.

  22. What is InputTransparent?
    Makes a control ignore touch events.

  23. How to animate controls?
    Use ViewExtensions (e.g., FadeToTranslateTo).

  24. What is SemanticProperties?
    Improves accessibility (e.g., screen readers).

  25. How to use WebView?

    xml
    <WebView Source="https://example.com"/>

3. Navigation (15)

  1. How to navigate between pages?

    csharp
    await Navigation.PushAsync(new DetailsPage());
  2. What is Shell?
    Container for flyouts, tabs, and URI navigation.

  3. How to use URI navigation?

    csharp
    await Shell.Current.GoToAsync("details?id=123");
  4. How to pass complex data?
    Serialize to JSON:

    csharp
    await Shell.Current.GoToAsync($"details?data={Uri.EscapeDataString(json)}");
  5. What is RegisterRoute?
    Maps URIs to pages:

    csharp
    Routing.RegisterRoute("details", typeof(DetailsPage));
  6. How to handle back navigation?

    csharp
    await Navigation.PopAsync();
  7. What is a Flyout?
    Hamburger-style menu in Shell.

  8. How to create a TabBar?

    xml
    <TabBar>
        <Tab Title="Home"><ShellContent ContentTemplate="{DataTemplate HomePage}"/></Tab>
    </TabBar>
  9. What is Modal navigation?
    Pages that dismiss independently (e.g., popups).

  10. How to prevent duplicate pages?
    Check navigation stack before pushing.

  11. What is INavigationService?
    Abstraction for decoupled navigation.

  12. How to deep link?
    Register URIs in App.xaml.cs:

    csharp
    App.Current.AppLinks.RegisterLink(...);
  13. How to customize navigation transitions?
    Override OnNavigating in Shell.

  14. What is NavigationPage?
    Legacy stack-based navigation.

  15. How to handle navigation guards?
    Override OnAppearing/OnDisappearing.


4. MVVM (20)

  1. What is MVVM?
    Model-View-ViewModel pattern for separation of concerns.

  2. How to implement INotifyPropertyChanged?

    csharp
    public class ViewModel : INotifyPropertyChanged {
        public event PropertyChangedEventHandler? PropertyChanged;
        void OnPropertyChanged([CallerMemberName] string name = "") => 
            PropertyChanged?.Invoke(this, new(name));
    }
  3. What is ICommand?
    Encapsulates UI actions:

    csharp
    public ICommand SaveCommand => new Command(() => Save());
  4. How to bind commands?

    xml
    <Button Command="{Binding SaveCommand}"/>
  5. What is ObservableCollection?
    Notifies UI when items change.

  6. How to use x:DataType?
    Enables compiled bindings:

    xml
    <StackLayout x:DataType="local:ViewModel">
        <Label Text="{Binding Name}"/>
    </StackLayout>
  7. What is ValueConverter?
    Transforms data for binding:

    csharp
    public class BoolToColorConverter : IValueConverter {...}
  8. How to validate input?
    Use data annotations:

    csharp
    [Required(ErrorMessage = "Required")]
    public string Username { get; set; }
  9. What is MessagingCenter?
    Pub/sub communication:

    csharp
    MessagingCenter.Send(this, "Refresh");
  10. How to use CommunityToolkit.MVVM?
    Simplifies MVVM with attributes:

    csharp
    [ObservableProperty] string name;
  11. What is Behavior?
    Reusable UI logic (e.g., validation).

  12. How to debug binding errors?
    Check Output window for binding logs.

  13. What is BindingMode?
    Defines binding direction (OneWay, TwoWay).

  14. How to bind to a parent's context?

    xml
    <Label Text="{Binding Source={RelativeSource AncestorType={x:Type Page}}, Path=BindingContext.Title}"/>
  15. What is FallbackValue?
    Default value if binding fails.

  16. How to use MultiBinding?
    Binds multiple properties to one control.

  17. What is INotifyDataErrorInfo?
    Advanced validation interface.

  18. How to bind to an indexer?

    xml
    <Label Text="{Binding Items[0]}"/>
  19. What is RelayCommand?
    Lightweight ICommand implementation.

  20. How to test ViewModels?
    Use xUnit/Moq:

    csharp
    [Fact]
    public void TestSave() {
        var vm = new ViewModel();
        vm.SaveCommand.Execute(null);
        Assert.True(vm.IsSaved);
    }

5. Platform-Specific (15)

  1. How to access camera?

    csharp
    var photo = await MediaPicker.CapturePhotoAsync();
  2. What is DependencyService?
    Resolves platform-specific implementations.

  3. How to use Platforms/ folders?
    Place platform-specific code in Platforms/AndroidPlatforms/iOS.

  4. How to request permissions?

    csharp
    var status = await Permissions.RequestAsync<Permissions.Camera>();
  5. What is DeviceInfo?
    Provides device details (OS, model).

  6. How to handle Android back button?
    Override OnBackButtonPressed.

  7. What is Custom Renderers?
    Legacy way to customize native controls.

  8. How to use Handlers?
    MAUI's replacement for renderers:

    csharp
    Microsoft.Maui.Handlers.ButtonHandler.Mapper.AppendToMapping(...);
  9. How to access native APIs?
    Use DependencyService or partial classes:

    csharp
    #if ANDROID
    // Android-specific code
    #endif
  10. What is Essentials?
    Cross-platform APIs (geolocation, sensors).

  11. How to play sounds?
    Use MediaElement or platform APIs.

  12. How to handle iOS Safe Area?

    xml
    <ContentPage xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
                 ios:Page.UseSafeArea="True">
  13. How to create a splash screen?
    Add platform-specific splash screen assets.

  14. What is MacCatalyst?
    macOS implementation of MAUI.

  15. How to debug platform code?
    Use #if DEBUG + platform debuggers.


6. Performance (10)

  1. How to optimize startup?
    Enable AOT, lazy-load resources.

  2. What is Compiled Bindings?
    Pre-compiles bindings for speed.

  3. How to reduce APK size?
    Enable linking (<PublishTrimmed>true</PublishTrimmed>).

  4. What is Fast Renderers?
    Flattens view hierarchy for native controls.

  5. How to profile?
    Use Visual Studio Diagnostics Tools.

  6. What is WeakReferenceManager?
    Prevents memory leaks in events.

  7. How to optimize CollectionView?
    Use DataTemplateSelector + virtualization.

  8. What is OnAppearing?
    Lifecycle method for page load.

  9. How to cache images?
    Use FFImageLoading or ImageSourceConverter.

  10. How to disable XAML compilation?

    xml
    <ContentPage x:Class="..." x:Compile="False">

Key Takeaways:

  • Shell for advanced navigation

  • MVVM for clean architecture

  • Handlers replace custom renderers

  • AOT for Android performance

  • Platforms/ for OS-specific code

No comments:

Post a Comment

Complete Guide: Building a Live Cricket Streaming App for 100M Users

Comprehensive guide to building a scalable live cricket streaming platform for 100M users, covering backend infrastructure, streaming techno...