104 строки
5.7 KiB
XML
104 строки
5.7 KiB
XML
<Namespace Name="Xamarin.Forms">
|
|
<Docs>
|
|
<summary>Cross-platform, natively-backed UI toolkit.</summary>
|
|
<remarks>
|
|
<para>Xamarin.Forms is a cross-platform, natively-backed UI toolkit abstraction that allows developers to create user interfaces that can be shared across Android, iOS, and Windows Phone. Because the user interfaces use the native controls of the target platforms, they have the appearance and, importantly, the responsiveness of natively built apps.</para>
|
|
<format type="text/html">
|
|
<h2>Hello, Xamarin.Forms!</h2>
|
|
</format>
|
|
<para>The user-experience of a Xamarin.Forms application is usually defined in a cross-platform shared project (either a Portable Class Library or a Shared Project) and combined with platform-specific projects that, at the least, initialize the native platform rendering (note the call to <c>Forms.Init()</c> in the platform code samples below) and, more generally, extend the user-experience and user-interface in platform-specific manners (for instance, by accessing platform-specific sensors or capabilities).</para>
|
|
<para>The dependencies are one-way: the platforms depend on the shared project, but not vice-versa:</para>
|
|
<para><img href="XamarinForms-ns.SharedProject.png"/></para>
|
|
<para>
|
|
The Solution Explorer for a cross-platform "Hello, World!" app might look like this:</para>
|
|
<para><img href="XamarinForms-ns.SolutionPad.png"/></para>
|
|
<para>The shared portion of the Xamarin.Forms code might look like this:</para>
|
|
<example>
|
|
<code lang="C#"><![CDATA[
|
|
public class App : Xamarin.Forms.Application
|
|
{
|
|
public App ()
|
|
{
|
|
MainPage = new ContentPage
|
|
{
|
|
Content = new Label
|
|
{
|
|
Text = "Hello, Forms !",
|
|
VerticalOptions = LayoutOptions.CenterAndExpand,
|
|
HorizontalOptions = LayoutOptions.CenterAndExpand,
|
|
},
|
|
};
|
|
}
|
|
}
|
|
]]></code>
|
|
</example>
|
|
<para>The iOS platform code would look like this:</para>
|
|
<example>
|
|
<code lang="C#"><![CDATA[
|
|
[Register("AppDelegate")]
|
|
public class AppDelegate : FormsApplicationDelegate
|
|
{
|
|
UIWindow window;
|
|
|
|
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
|
|
{
|
|
Forms.Init();
|
|
|
|
LoadApplication (new App ());
|
|
|
|
return base.FinishedLaunching (app, options);
|
|
}
|
|
}
|
|
]]></code>
|
|
</example>
|
|
<para>The Android platform code would look like this:</para>
|
|
<example>
|
|
<code lang="C#"><![CDATA[
|
|
[Activity(Label = "HelloXamarinFormsWorld", MainLauncher = true)]
|
|
public class MainActivity : FormsApplicationActivity
|
|
{
|
|
protected override void OnCreate(Bundle bundle)
|
|
{
|
|
base.OnCreate(bundle);
|
|
|
|
Forms.Init(this, bundle);
|
|
|
|
LoadApplication (new App ());
|
|
}
|
|
}
|
|
]]></code>
|
|
</example>
|
|
<para>And the Windows Phone code would look like this:</para>
|
|
<example>
|
|
<code lang="C#"><![CDATA[
|
|
public partial class MainPage
|
|
{
|
|
public MainPage()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Forms.Init();
|
|
|
|
LoadApplication (new HelloXamarinFormsWorld.App ());
|
|
}
|
|
}
|
|
]]></code>
|
|
</example>
|
|
<para>The resulting app looks like this on the various devices:</para>
|
|
<para><img href="XamarinForms-ns.TripleScreenShot.png"/></para>
|
|
<format type="text/html">
|
|
<h2>Elements in Xamarin.Forms</h2>
|
|
</format>
|
|
<para>Important types in the Xamarin.Forms namespace include <see cref="T:Xamarin.Forms.Page"/>, <see cref="T:Xamarin.Forms.View"/>, and <see cref="T:Xamarin.Forms.Layout"/>. <see cref="T:Xamarin.Forms.Page"/>s typically correspond with controller objects (Activities in the Android world, UIViewControllers in the iOS world), <see cref="T:Xamarin.Forms.View"/>s with controls or widgets, and <see cref="T:Xamarin.Forms.Layout"/>s arrange <see cref="T:Xamarin.Forms.View"/>s on other <see cref="T:Xamarin.Forms.View"/>s. These types are all derived from <see cref="T:Xamarin.Forms.Element"/>.</para>
|
|
<format type="text/html">
|
|
<h2>Model-View-ViewModel and Xamarin.Forms</h2>
|
|
</format>
|
|
<para>Application developers use the Model-View-ViewModel (MVVM) pattern to create Xamarin.Forms apps that cleanly separate the concerns of data presentation and user interface from the concerns of data storage and manipulation. The <see cref="N:Xamarin.Forms" /> framework enables this by providing, among a few other related types, the <see cref="T:Xamarin.Forms.BindableObject" /> and <see cref="T:Xamarin.Forms.BindableProperty" /> classes. Objects that inherit from <see cref="T:Xamarin.Forms.BindableObject" /> can be bound to members of type <see cref="T:Xamarin.Forms.BindableProperty" /> on other objects.</para>
|
|
<para>A <see cref="T:Xamarin.Forms.BindableObject" /> maintains dictionary of <see cref="T:Xamarin.Forms.BindableProperty" /> names and an association with their corresponding binding contexts--simply the object on which the <see cref="T:Xamarin.Forms.BindableProperty" /> is defined and that the application developer has assigned to the <see cref="P:Xamarin.Forms.BindingObject.BindingContext" /> property--through a <see cref="T:Xamarin.Forms.Binding" />. See <see cref="T:Xamarin.Forms.BindableObject" /> for more information.</para>
|
|
</remarks>
|
|
<related type="article" href="http://developer.xamarin.com/guides/cross-platform/xamarin-forms/introduction-to-xamarin-forms/">Introduction to Xamarin.Forms</related>
|
|
<related type="article" href="http://developer.xamarin.com/guides/cross-platform/xamarin-forms/controls/">Xamarin.Forms View Gallery</related>
|
|
|
|
</Docs>
|
|
</Namespace>
|