简体   繁体   English

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

[英]Xamarin Forms Multiple Custom Controls Per Page

I have some custom renderers and Controls that works. 我有一些自定义渲染器和控件。 But how can I place multiple custom controls in one Xamarin Forms xaml page.? 但是,如何在一个Xamarin Forms xaml页面中放置多个自定义控件。

Thanks 谢谢

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

Just add the namespace of your custom controls in the header of the xaml page then reference them within the layout. 只需在xaml页面的标题中添加自定义控件的名称空间,然后在布局中引用它们即可。 For example the custom controls in the below code are in the PCL under the folder CustomControls. 例如,以下代码中的自定义控件位于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