RandomBoy
RandomBoy

Reputation: 464

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.?

Thanks

Upvotes: 0

Views: 649

Answers (2)

ClintL
ClintL

Reputation: 1453

Just add the namespace of your custom controls in the header of the xaml page then reference them within the layout. For example the custom controls in the below code are in the PCL under the folder 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>

Upvotes: 1

joe
joe

Reputation: 1125

Wrap everything in whatever normal Layouts you want, e.g. a StackLayout.

Upvotes: 1

Related Questions