如何在Xamarin Cross Platform xaml中添加评级栏 [英] How to Add Rating Bar in Xamarin Cross Platform xaml

查看:79
本文介绍了如何在Xamarin Cross Platform xaml中添加评级栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在xamarin便携式课程中添加评分栏.我搜索了很多, 使用syncfusion评分栏,但没有进度.我使用了nuget 3rd party工具.但是等级栏不显示.我想使用同步融合之类的内置工具 并显示评分

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

我的代码

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

推荐答案

您可以参考以下博客

使用xamarin表单创建等级"栏的步骤(自定义控件) https://xamarincodingtutorial.blogspot.com/2019/04/p_29.html

Step to create Rating bar using xamarin form (Custom Control) https://xamarincodingtutorial.blogspot.com/2019/04/p_29.html

这篇关于如何在Xamarin Cross Platform xaml中添加评级栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆