Can I create an interface in Xamarin.Forms using XAML

I am trying to create a cross-platform application using Xamarin.Forms. As far as I know, the user interface will be created from the code, and the .axml file will be generated automatically.

Can I modify the .axml file to edit the user interface? I tried editing, but all that appears is what is written in the code. i.e.: hello forms

UPDATE

 public static Page GetMainPage () { return new simplerow (); } 
+5
source share
3 answers

In Xamarin.Forms, you can create your pages from markup definitions that are common to all platforms.

Typically, you will write all your content pages using Xamarin.Forms , however you can mix and match your own pages in the application if you wish.

These common shared pages, written in Xamarin.Forms , will probably be in a PCL or Common project so that they can then be reused in platform-specific projects, each of which targets a specific OS platform.

You can write these shared pages, either in code or in XAML . You can even write several pages one way and the other if you want.

A Xamarin.Forms page is processed at runtime by interpreting the created page composition.

Each control specified on the page has its own platform-specific rendering, behind the scenes, which will produce the output that this OS is aimed at.

When writing Xamarin.Forms pages, for most, you will begin to learn a new way to create pages that abstracts from the intricacies of creating mobile applications on every other OS platform.

Therefore, there is no editable .axml that is created, etc. when you write your pages using the Xamarin.Forms markup and controls, and even your own or other user controls to create your own application pages.

The following link shows some examples of how to write XAML pages.

The following link shows some examples of how to write code-behind pages.

+7
source

Along with the previous answer re: .xaml instead of .axml, you need to remember the startup code in app.cs in order to use your new .xaml form. Replace "new ContentPage {...};" with "new MyForm ()"; (where "MyForm" is the name of your shiny new XAML form).

EDIT: Download the project from the delete link. Comments below ...

Here I see a few questions. I think you may have to go through the walkthroughs and sample applications provided by Xamarin to speed up the concepts of XF applications.

First you try to use Activity as your application page. In the Xamarin Forms application, this should be a view of some kind, and not visual for the platform, for example Activity.

Secondly, delete the file "test.xml" from the Resources / Layout folder of the Android project. while XAML files are really XML, they have 1) have a .xaml file extension and 2) belong to a common project.

Here you need to make your project work: (I assume that you are using VS here in Xamarin Studio, it is slightly different.)

  • Right-click your generic "testforms" project.
  • Click "Add" in the context menu and select "New Item"
  • In the dialog that appears, select “Forms XAML Page” and in the Name field, enter a name (for example, “MyForm”) (If you are using XS, select “New File” and “Forms ContentPage”).
  • This will add two files to your project: a XAML file containing your layout (for example, MyForm.xaml) and a file with code (for example: MyForm.xaml.cs).
  • Open the XAML file and modify the Label element so that the Text attribute is

    Text = "Hello world!"

  • Modify the GetMainPage body in the App.cs application as follows:

    return a new MyForm ();

  • Run the application

Hope this helps!

+2
source

You are wrong. Forms are created either using code or using XAML. At the platform level, no axml or anything permanent is generated; everything is executed at runtime (XAML is sorted at compile time).

So, change the code or XAML if you want to change something. Or, if you need something more demanding than considering either subclasses of the existing renderer, or create your own.

+1
source

Source: https://habr.com/ru/post/1204239/


All Articles