# Xamarin

{% embed url="<https://dotnet.microsoft.com/en-us/apps/xamarin>" %}

## Xamarin Forms

{% embed url="<https://learn.microsoft.com/en-us/xamarin/xamarin-forms/>" %}

## Introduction

* `Xamarin.Forms` is a framework for creating cross-platform native mobile apps with C# and XAML, by using Visual Studio.
* Xamarin.Forms isn't rendered in a webview. Instead, internally it uses the Android SDK or the iOS SDK to create native controls for native performance.
* `Xamarin.Essentials` handles many of the common needs of mobile apps that *don't* have to do with the UI. That means with `Xamarin.Essentials` NuGet package, you can access things like the GPS, the accelerometer, and battery and network states etc.

### Pages

* Pages are the root of the UI hierarchy in `Xamarin.Forms`.
* On **iOS**, the Page is mapped to `ViewController`, on **Android**, it is mapped to somewhat like `Activity` and on **Universal Windows Platform**, it is mapped to `Page`.&#x20;
* Types
  * `ContentPage`: A content page simply displays its contents.
  * `MasterDetailPage`: This hosts drawer type navigation as well as split views. It has two key properties, `Master` and `Detail`, each of which is assigned a `ContentPage`.
  * `NavigationPage`: This adds the familiar navigation bar to the top of the screen, but more importantly manages a *navigation stack*. This stack allows the user to navigate backward to previous screens.
  * `TabbedPage`: This is the root page used for tab navigation.

### Layouts <a href="#layouts" id="layouts"></a>

![](/files/FyTZ2pC1af7NmmrZSVEK)

* `StackLayout` - Lays out controls in a top-to-bottom or left-to-right stack depending on an orientation property.
* `AbsoluteLayout` - Lets us set exact coordinates for controls.
* `RelativeLayout` - Lets us define relationships between multiple controls' sizes and shapes. For instance, `button1` should be 50% the size of `entry1` and should be 5 points below it.
* `Grid` - Lays out its controls according to a column and row location we set. We can define the column and row sizes as well as spans, so grid layouts don't necessarily have a "checkerboard look" to them.
* `ScrollView` - Technically, this isn't considered a layout, since it only holds one child directly but it's very important to screen layouts. By default, all the other layouts will actually try to squeeze their contents, if necessary, to fit on a single screen. But if those other layouts are put inside a ScrollView, then the screen can scroll and squeezing the contents isn't necessary.

{% embed url="<https://youtube.com/playlist?list=PLdo4fOcmZ0oU10SXt2W58pu2L0v2dOW-1>" %}

{% embed url="<https://dotnet.microsoft.com/en-us/platform/support/policy/xamarin>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dailyjournal.gitbook.io/notes/app-frameworks/xamarin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
