Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Rating > binding in rating?

Not answered binding in rating?

Feed from this thread
  • sivakanth avatar

    Posted on Mar 1, 2011 (permalink)

    Hello Telerik Team,

    I have small doubt in wpf rating,
         How to bind rad rating? Bcoz i want to store the rated value in database.
    our telerik version is 2010_2_0723_DEV.

    Reply

  • Petar Mladenov Petar Mladenov admin's avatar

    Posted on Mar 3, 2011 (permalink)

    Hello sivakanth,

    Binding the value of RadRating could be achieved by using a ViewModel like so:
    <telerik:RadRating Width="120" Height="40" Value="{Binding RatingValue}" x:Name="ratingControl"/>
    class RatingViewModel
        {
            public double RatingValue
            {
                get;
                set;
            }
        }
    public MainWindow()
          {
              InitializeComponent();
              this.ratingControl.DataContext = new RatingViewModel() { RatingValue = 4.5 };
          }
    Please let us know if this fits in your scenario.

    Greetings,
    Petar Mladenov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

    Reply

  • Dan avatar

    Posted on Apr 3, 2012 (permalink)

    This example is not working. the value is read from the binding, however the value is not set back to the binding. 

    This is my workaround

        Private Sub RadRating1_ValueChanged(sender As Object, e As System.Windows.RoutedPropertyChangedEventArgs(Of Double?)) Handles RadRating1.ValueChanged
            CType(DataContext, MyObject).Rating = RadRating1.Value
        End Sub


    Version: 2012.1.215.40

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Apr 4, 2012 (permalink)

    Hello Dan,

    You don't have to handle the ValueChanged event. Instead you can set the binding mode of the Value property to TwoWay:
    <telerik:RadRating Value="{Binding Rating, Mode=TwoWay}" />

    I attached a sample project demonstrating this approach. Please give it a try and let us know if it helps.

    Kind regards,
    Tina Stancheva
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
    Attached files

    Reply

  • Dan avatar

    Posted on Apr 4, 2012 (permalink)

    Thank you Tina for your response.  Your suggestion works, however, Telerik should change this to the default behavior. It's more reasonable to assume 2 way binding on every control until otherwise set that way.

    Thanks again for your help.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Rating > binding in rating?