Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to display the UI designed by XAML to the interface in Xamarin XAML language

Shulou Source: shulou.com Published: 2022-06-01 10:13:29 09月10日 Update

This article is about how to display UI designed by XAML in the Xamarin XAML language into the interface. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

If the UI is designed through XAML, the contents of the XAML can be displayed to the user, that is, on the interface. Because of the different ways to create XAML files, the way the contents of XAML are displayed on the interface is also different. According to the different ways of creating XAML files, the following explains for developers how to display the contents of XAML on the interface.

Note: previously we used Visual Studio to create XAML files and Xamarin Studio to create XAML files in two ways: creating XAML files after creating a project and creating XAML files while creating a project. There are two ways to create XAML: creating a XAML file after creating a project and creating a XAML file while creating a project. There are two ways to display it to the interface.

Create the XAML file after creating the project

If the developer creates the XAML file after creating the project, you need to display the contents of the XAML file to the interface. You need to open the App.cs file (App.cs file is a file in Visual Studio. If Xamarin Studio needs to open * * .cs, the project name specified here), modify the code in this file. The modified code is as follows:

Using System

Using System.Collections.Generic

Using System.Linq

Using System.Text

Using Xamarin.Forms

Namespace Hello

{

Public class App: Application

{

Public App ()

{

/ / The root page of your application

MainPage = new XAMLPage (); / / XAMLPage is the XAML file created

}

……

}

}

When the program is run, the contents of the XAML file will be displayed on the interface, thus realizing the display to the user.

Create a XAML file when you create a project

If the developer created the XAML file while creating the project, we don't need to do anything to display the content on the interface. When you run the program, you will see that the contents of the XAML file are displayed in the interface.

Thank you for reading! This is the end of the article on "how to display the UI designed by XAML in Xamarin XAML language to the interface". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: File interface content project way design at the same time developer development language different code is in more user program article run good practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Microsoft vpn Apple MySQL