Articles in this section
Category / Section

How to prevent mouse interaction in UWP Rating control?

3 mins read

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



Conclusion

I hope you enjoyed learning how to prevent mouse interaction in UWP Rating control.

You can refer to UWP Rating feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our UWP Rating example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied