Microsoft Learn

Your source for .NET MAUI documentation and samples

Weather App Sample

This sample demonstrates a cross-platform weather application built with .NET MAUI. It showcases how to fetch data from a public API, display it in a user-friendly interface, and handle common UI patterns.

The application provides real-time weather information, including current conditions, forecasts, and location-based search. It's designed to be a practical example of how to leverage .NET MAUI for building robust mobile and desktop applications.

MAUI Weather App Screenshot

Key Features Demonstrated:

API Integration

Fetches weather data from a public API (e.g., OpenWeatherMap) using modern .NET networking capabilities.

UI Design Patterns

Employs MVVM (Model-View-ViewModel) pattern for clean separation of concerns and maintainable UI.

Cross-Platform UI

Utilizes .NET MAUI's XAML-based UI for a single codebase that targets Android, iOS, macOS, and Windows.

Data Display

Efficiently displays complex data like weather icons, temperatures, and forecast details.

Navigation

Implements intuitive navigation between different views, such as current weather and forecast screens.

Localization (Optional)

Includes examples of how to localize the application for different languages.

Project Structure:

The project follows a standard .NET MAUI structure:

├── App.xaml
├── AppShell.xaml
├── MainPage.xaml
├── Views/
│ ├── WeatherView.xaml
│ └── ForecastView.xaml
├── ViewModels/
│ ├── WeatherViewModel.cs
│ └── ForecastViewModel.cs
├── Models/
│ └── WeatherData.cs
├── Services/
│ └── WeatherService.cs
└── Resources/

Getting the Code:

You can find the full source code for this sample on our official GitHub repository:

View on GitHub

Further Learning:

Explore more .NET MAUI samples and tutorials on Microsoft Learn.