I have problem an update control Rating work with mvvm

1 Answer 85 Views
Rating
Sergio
Top achievements
Rank 1
Iron
Sergio asked on 27 Oct 2022, 01:33 PM

Hi,

This control Rating no update always, when the property is chance in the viewmodel, no always this control updated, somebody why happed this?

1 Answer, 1 is accepted

Sort by
0
Antoan
Telerik team
answered on 01 Nov 2022, 10:31 AM

Hello Sergio,

I have tried the following scenario to try and reproduce this case. I created a property of type double in the ViewModel which value would change from a slider and update the Value of the Rating through the same binding. However I do not seem to reproduce the issue.

The code looks as follows.

XAML:

<Slider Value="{Binding RatingValue}" Minimum="1" Maximum="7"/>
<telerik:RadShapeRating AutomationId="radRating"
                                             Value="{Binding RatingValue, Mode=TwoWay}"
                                             ItemsCount="7"
                                             ItemsSpacing="20" />

ViewModel:

public class ViewModel : NotifyPropertyChangedBase
    {
        private double ratingValue;

        public double RatingValue
        {
            get => this.ratingValue;
            set => this.UpdateValue(ref this.ratingValue, value);
        }
    }

Result:

Make sure that you have set the binding mode to two way, and implement PropertyChanged for the propery bound to the Rating.Value.  

Give the suggestion a try and let me know if it works on your side. If the issue still persists, send me the exact setup you have, so I can test on my side.

Regards,
Antoan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Rating
Asked by
Sergio
Top achievements
Rank 1
Iron
Answers by
Antoan
Telerik team
Share this question
or