Additional Content in a custom Xamarin.Forms Control (XAML)

If a custom control is created with content, is there any way to specify additional content:
(Example here StatusView is a ContentView with a Grid for its Content)
I would like to take whatever additional controls are added via XAML and add them into the grid from the custom control

<?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:vm="clr-namespace:MobileClient.ViewModels;assembly=MobileClient" xmlns:controls="clr-namespace:MobileClient.Controls;assembly=MobileClient" x:Class="MobileClient.Views.StatusView" Title="{Binding Title}" Icon="{Binding Icon}"> <ContentPage.BindingContext> <vm:StatusViewModel /> </ContentPage.BindingContext> <ContentPage.Content> <!-- Style row just defines RowHeight = 100 --> <ListView Style="{StaticResource row}" ItemsSource="{Binding Statuses}"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <ViewCell.View> <controls:StatusView Status="{Binding Name}" StatusColor="{Binding Color, Converter={StaticResource colorizer}, Mode=OneWay}" Title="{Binding Code}" Description="{Binding StatusType}"> **<!-- Additional XAML Here with Binding -->** </controls:StatusView> </ViewCell.View> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </ContentPage.Content> </ContentPage>

Best Answer

Answers

  • Thanks, That has solved my problem and I have used the StackLayout like mentioned.

  • JamesWeaverJamesWeaver USMember

    @ DavidStrickland0 or anyone else, I would like to hear more about this limitation. I am currently working with extending the SatelliteMenuButton control (https://components.xamarin.com/view/satellite-menu) to work in my PCL app. I have been able to successfully take the platform specific implementation and extend to work with my PCL app using custom renderers.

    Where I am running into issues is with the Xaml. I am able to define the control without issue but I want the ability to define the menu items in Xaml. I am stumbling over this currently and most recently saw the ContentPropertyAttribute that led me to your post.

    Are you saying that the shortcoming of the Xamarin Xaml Renderer is prohibiting this from happening?
    Im trying to define as:





Sign In or Register to comment.