Reputation: 122
I want to add rating bar in xamarin portable class. I had searched a lot and use syncfusion rating bar but not having progress.I had used nuget 3rd party tools. But rating bar dont display. I want to use inbuilt tool like syncfusion and displays rating
My Code
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyVoucherSpy.Portable.Views.AboutPage"
xmlns:rating="clr- namespace:Syncfusion.SfRating.XForms;assembly=Syncfusion.SfRating.XForms"
>
<ListView
CachingStrategy="RecycleElement"
SeparatorColor="Transparent"
HasUnevenRows="True"
x:Name="listView">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid x:Name="LayoutRoot">
Rating bar I had used
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="300"/>
</Grid.RowDefinitions>
<BoxView BackgroundColor="#700AB9" />
<Image Source="{Binding DefaultImageUrl}" HeightRequest="500" >
</Image>
<StackLayout>
<Image Source="hrtgray.png" HeightRequest="20" Margin="0,10,350,0" WidthRequest="20" />
<Label Margin="40,-25,0,100" Text="{Binding Favourite}" FontSize="Small" TextColor="#ffffff"/>
<Label Margin="20,0,0,0" Text="{Binding CategoryName}" TextColor="#ffffff" FontSize="Small"/>
<Label Margin="20,0,0,0" Text="{Binding Headline}" TextColor="#ffffff" FontSize="Large"/>
<Label Margin="100,0,0,10" Text="{Binding UserRated}" TextColor="#ffffff" FontSize="Small"/>
<Image Source="map.png" HeightRequest="15" Margin="0,30,0,0" WidthRequest="15" />
<Label Margin="0,-25,0,100" Text="{Binding Miles}" TextColor="#ffffff" FontSize="Small"/>
</StackLayout>
<rating:SfRating x:Name="rating" ItemCount="3" />
<!--<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="5"/>
</Grid.RowDefinitions>
<Label Text="{Binding Headline}" TextColor="#FFFFFF"/>
</Grid>-->
<!--<Image Grid.Row="2" Source="hrtgray"/>
<Label Grid.Row="4" Text="{Binding Exclusive}" TextColor="#FFFFFF"/>
<Label Text="{Binding CategoryName}" TextColor="#FFFFFF"/>
<Label Text="{Binding UserRated}" TextColor="#FFFFFF"/>
<Label Text="{Binding AverageRated}" TextColor="#FFFFFF"/>
<Label Text="{Binding Favourite}" TextColor="#FFFFFF"/>
<Label Text="{Binding Miles}" TextColor="#FFFFFF"/>-->
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage.Content>
Upvotes: 1
Views: 8548
Reputation: 416
You can refer following blog
Step to create Rating bar using xamarin form (Custom Control) https://xamarincodingtutorial.blogspot.com/2019/04/p_29.html
Upvotes: 2
Reputation: 13092
Nish from our evangelism team did blog post discussing creating a rating controls in Xamarin.Forms
You can find the source and read more about it here: https://blog.xamarin.com/behaviors-in-xamarin-forms/
Upvotes: 0