我有一些自定义渲染器和控件可行。但是如何在一个Xamarin Forms xaml页面中放置多个自定义控件。?
由于
答案 0 :(得分:1)
将所有内容包裹在您想要的任何正常布局中,例如一个StackLayout。
答案 1 :(得分:1)
只需在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>