)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can prevent user interaction with SfRating control?

Platform: UWP |
Control: SfRating |
Published Date: March 10, 2016 |
Last Revised Date: June 23, 2019 |
Product Version: 13.4.0.53

To prevent the interaction with the SfRating control, set IsReadOnly property to true. When this property is enabled, we could not able to rate the SfRatingItem. But it allows to perform interactions with tooltip and PointerOverFill when precision is changed. In order to prevent this interaction, set ShowTooltip to false and colors for PointerOverFill and PointerOverStroke.

Prevent Mouse interactions with the control by setting IsHitTestVisible property as false.

The same has been explained in the following code example

Code snippet:

XAML:

<Input:SfRating Value="2" ItemsCount="5" HorizontalAlignment="Center" 
                          VerticalAlignment="Center Precision="Exact" 
                          Foreground="Yellow" 
                          ShowToolTip="False" IsReadOnly="True">
     <Input:SfRating.ItemContainerStyle>
      <Style TargetType="Input:SfRatingItem">
      <Setter Property="Height" Value="40"/>
      <Setter Property="Width" Value="40"/>
      <Setter Property="RatedFill" Value="Yellow"/>
      <Setter Property="PointerOverFill" Value="Yellow"/>
      <Setter Property="PointerOverStroke" Value="Transparent"/>
      </Style>
     </Input:SfRating.ItemContainerStyle>
</Input:SfRating>

 

C#:      

            SfRating sfrating = new SfRating()
            {
                Value = 2,
                ItemsCount = 5,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                ShowToolTip = false,
                IsReadOnly = true,
                Foreground = new SolidColorBrush(Colors.Yellow),
                Precision = Syncfusion.UI.Xaml.Primitives.Precision.Exact
 
            };
            Style style = new Style { TargetType = typeof(SfRatingItem) };
            Setter setter = new Setter();
            setter.Property = SfRatingItem.HeightProperty;
            setter.Value = 40;
 
            Setter setter1 = new Setter();
            setter1.Property = SfRatingItem.RatedFillProperty;
            setter1.Value = new SolidColorBrush(Colors.Yellow);
            Setter setter2 = new Setter();
            setter2.Property = SfRatingItem.WidthProperty;
            setter2.Value = 40;
 
            Setter setter3 = new Setter();
            setter3.Property = SfRatingItem.PointerOverFillProperty;
            setter3.Value = new SolidColorBrush(Colors.Yellow);
 
            Setter setter4 = new Setter();
            setter4.Property = SfRatingItem.PointerOverStrokeProperty;
            setter4.Value = new SolidColorBrush(Colors.Transparent);
 
            style.Setters.Add(setter);
            style.Setters.Add(setter1);
            style.Setters.Add(setter2);
            style.Setters.Add(setter3);
            style.Setters.Add(setter4);
            sfrating.ItemContainerStyle = style;
 
            grid.Children.Add(sfrating);
 

 

Output:

 

SfRating control interaction in UWP

2X faster development

The ultimate UWP UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon