本文介绍了我可以使用XAML在Xamarin.Forms中设计UI吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Xamarin.Forms创建一个跨平台应用程序.据我所知,UI将通过代码创建,.axml文件将自动生成.

I'm trying to create a cross platform app using Xamarin.Forms. As far as I know, the UI will be created from the code and the .axml file will be generated automatically.

我可以修改.axml文件来编辑UI吗?我尝试进行编辑,但是所有出现的都是代码中编写的内容.即:hello forms

Can I modify the .axml file to edit the UI? I tried editing but all that comes up is what is written in the code. ie: hello forms

更新

public static Page GetMainPage ()
        {
            return new simplerow ();
        }

推荐答案

Xamarin.Forms 中,您可以根据在所有平台上共享的标记定义来创建页面.

In Xamarin.Forms you can create your pages from markup definitions that are shared across all platforms.

通常,您将使用 Xamarin.Forms 来编写所有内容页面,但是,您可以根据需要将本机页面混合并匹配到应用程序中.

Typically you will write all your content pages using Xamarin.Forms, however you can mix-and-match native pages into an application should you so wish.

这些用 Xamarin.Forms 编写的共享通用页面可能驻留在 PCL 项目或 Shared Project 项目中,因此可以然后在特定于平台的项目中重复使用,每个项目都针对特定平台OS .

These shared common pages, written in Xamarin.Forms, will reside maybe in a PCL project, or a Shared Project so these can then be re-used in the platform-specific projects, each targeting a specific platform OS.

您可以使用 code XAML 编写这些通用页面.您甚至可以选择以一种方式编写某些页面,如果愿意的话,另一些方式也可以.

You can write these common pages, either in code, or in XAML. You can even choose to write some pages one way, and some the other if you so choose.

Xamarin.Forms 页面在运行时通过解释已创建的页面组成来处理.

A Xamarin.Forms page is processed at runtime through the interpretation of the page composition that has been created.

在页面上指定的每个控件在幕后都有自己的特定于平台的渲染器,该渲染器将生成针对该 OS 的输出.

Each control that is specified on a page, has its own platform specific renderer, behind the scenes, that will produce output that is targetted to that OS.

在编写 Xamarin.Forms 页面时,最重要的是,您将开始学习一种创建页面的新方法,该方法是从在每个不同平台上创建移动应用程序的复杂性中抽象出来的.操作系统.

When writing Xamarin.Forms pages, for-the-most, you will start to learn a new way of creating pages that is abstracted from the intricacies of creating mobile applications on each different platform OS.

因此,不会生成没有可编辑的 .axml ,因为您将使用 Xamarin.Forms 标记和控件编写页面,并且甚至您自己的或其他自定义控件来生成自己的应用程序页面.

There is therefore no editable .axml that is generated etc as you will write your pages using Xamarin.Forms markup and controls, and even your own or other custom-controls to produce your own application pages.

以下链接显示了一些有关如何编写 XAML 的示例. >页面.

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

下面的链接显示了一些如何从隐藏代码进行编写的示例页面.

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

这篇关于我可以使用XAML在Xamarin.Forms中设计UI吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 04:46