Categories
.NET .NET 10 ASP.NET Core Aspire Automation Azure Blazor C# CLI Code Desktop Developer Getting Started Linux macOS Mobile Visual Studio VS Code Web What's New Windows

Using C# Ignored Directives: A Guide for Programmers

C# – Preprocessor Directives are highly useful for writing code that can be compiled conditionally, depending on factors like the target framework, target platform, or build configuration.

For example:

#if NET9_0_OR_GREATER
// The code within this block will execute only on .NET 9 or higher
#endif

#if ANDROID
// The code within this block will execute only on the Android OS
#endif

#if DEBUG
// The code within this block will execute only in Debug mode
#endif

C# – Ignored Directives have a similar syntax but are ignored by the compiler because they are for tooling.

The real purpose of this feature is to execute a C# source file directly from the CLI. It doesn’t need a project file. Now, even the plain console app requires a project file, despite the much-simplified top-level statements feature.

Categories
.NET .NET 8 .NET 9 .NET MAUI Android Blazor C# Desktop Developer General Hybrid iOS macOS Migration Mobile Tips Visual Studio VS Code Web Windows Xamarin Xamarin.Forms

Transitioning from Frame to Border in .NET MAUI

This is an article in the Developer Tips series, which offers concise hints to enhance productivity. You can access all the articles in this series here.

Border:

From .NET MAUI 9 onwards, the Frame control has been marked as obsolete, paving the way for more robust Border control.

An article has already been published detailing the comprehensive features of .NET MAUI 9.

The Border serves as a container control, akin to the Frame; however, it exhibits significantly greater flexibility, enabling the user to delineate any enclosed geometric shape.

Categories
.NET .NET 8 .NET 9 .NET MAUI Android Blazor C# Code Desktop Developer General Hybrid iOS macOS Mobile Toolkit Web What's New Windows Xamarin Xamarin.Forms

Enhance Gesture Binding with the Shared Toolkit

The year 2024 began with an article outlining the improvements in the Shared Toolkit through the optimization of specifying the Binding as a LINQ expression, without requiring an additional getter or setter.

Mainly, the Binding expression is statically typed, providing better control by aiding in identifying errors during compilation. Furthermore, it preserves the default binding behavior of the View, such as the two-way binding in the case of Entry, enabling editing. This behavior can be modified using the BindingMode parameter.

Categories
.NET MAUI Blazor Code Deep Dive Desktop Developer Hybrid Mobile Web Xamarin

Blazor – All along the way – Hybrid Apps

This is the fourth article in the .NET MAUI – Blazor series and have provided links for the other 3 articles previously published.

This article primarily focuses on the Blazor Hybrid scenarios.

The reason is the potential of Blazor, the modern web UI stack based on Razor SDK and allows to work with C# language constructs which can be used across multiple frameworks with the introduction of BlazorWebView, now officially supported on .NET MAUI, classic Windows desktop application frameworks such as Windows Forms (WinForms) and WPF.

Categories
.NET MAUI Deep Dive Desktop Developer Migration Mobile MVVM Templates Visual Studio Xamarin

Introducing Shared Class Library – Multi-target Xamarin.Forms and .NET MAUI from a single project

Very happy to announce the availability of the Shared Class Library project template, a library that targets both Xamarin.Forms and .NET MAUI from one single project.

We all know that .NET MAUI is an evolution of Xamarin.Forms targeting .NET 6 (as of this writing), a cross-platform UI stack (native UI) targeting the Android, iOS, macOS, and Windows platforms to complement the .NET toolchain (SDK & Workloads), and a single base class library (BCL).