I have a Custom Rating bar layout in Xamarin, I want to display it multiple times in my form but it is displaying only once even though i have declared it multiple times but is showing only one time & last layout.
<?xml version="1.0" encoding="UTF-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" Title="Reviews" xmlns:customcontrol="clr-namespace:MyApp.NestedLayouts" x:Class="MyApp.Pages.Reviews"> <ContentPage.Content> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="110"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="100"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Label Text="4.5" FontSize="30" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" FontAttributes="Bold"/> <StackLayout Grid.Column="1"> <customcontrol:RattingBar x:Name="layout1" ImageWidth="20" ImageHeight="20" RequiredStarValue="5" SelectedStarValue="5" FillStarImage="StarF.png" EmptyStarImage="star.png" /> <Label Text="2 Reviews"/> </StackLayout> <Grid Grid.ColumnSpan="2" Grid.Row="1"> <Grid.ColumnDefinitions> <ColumnDefinition Width="110"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="40"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <!-- Row 0 --> <customcontrol:RattingBar ImageWidth="18" ImageHeight="18" RequiredStarValue="5" x:Name="layout2" SelectedStarValue="5" FillStarImage="StarF.png" EmptyStarImage="star.png" /> <BoxView Grid.Column="1" HeightRequest="1" VerticalOptions="CenterAndExpand" BackgroundColor="{DynamicResource gray}"/> <Label Grid.Column="2" Text="1" HorizontalOptions="CenterAndExpand"/> <!-- Row 1 --> <customcontrol:RattingBar ImageWidth="18" ImageHeight="18" RequiredStarValue="4" Grid.Row="1" x:Name="layout3" SelectedStarValue="4" FillStarImage="StarF.png" EmptyStarImage="star.png" /> <BoxView Grid.Column="1" HeightRequest="1" VerticalOptions="CenterAndExpand" Grid.Row="1" BackgroundColor="{DynamicResource gray}"/> <Label Grid.Column="2" Text="1" HorizontalOptions="CenterAndExpand" Grid.Row="1"/> </Grid> </Grid> </ContentPage.Content> </ContentPage>
This is the layout Which i want to use multiple times but can't achieve (I have added my Views in backend).
<?xml version="1.0" encoding="UTF-8"?> <ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyApp.NestedLayouts.RattingBar"> <StackLayout Orientation="Horizontal"/> </ContentView>