繁体   English   中英

Xamarin每页形成多个自定义控件

[英]Xamarin Forms Multiple Custom Controls Per Page

我有一些自定义渲染器和控件。 但是,如何在一个Xamarin Forms xaml页面中放置多个自定义控件。

谢谢

将所有内容包装在所需的任何常规布局中,例如StackLayout。

只需在xaml页面的标题中添加自定义控件的名称空间,然后在布局中引用它们即可。 例如,以下代码中的自定义控件位于PCL的CustomControls文件夹下。

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"    
             xmlns:customcontrols="clr-namespace:MyNameSpace.CustomControls;assembly=MyNameSpace"
             x:Class="MyNameSpace.Views.Page_One"
             Title="Page One">

<StackLayout x:Name="stackContent" VerticalOptions="Fill"HorizontalOptions="Fill">

<customcontrols:MY_Entry x:Name="entry1" ></customcontrols:MY_Entry>

<customcontrols:MY_Label x:Name="label1" ></customcontrols:MY_Label>

</Stacklayout>

</ContentPage>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM