Graph Rating Value

6 posts, 0 answers
  1. Ramjet
    Ramjet avatar
    51 posts
    Member since:
    Jul 2009

    Posted 12 Apr 2012 Link to this post

    Hello,

    I am using your (Telerik) Bar_Rating_WPF custom control for bar graph style ratings. Everything displays well and the click action selects the proper rating bar. Where I am having difficulty is setting or getting a value. I don't see how I can set a datacontext?

    FWIW I add the control at runtime:
    Bar_Rating_WPF uctrl_ConfOpn = new Bar_Rating_WPF();
    grd_ConfOpn.Children.Add(uctrl_ConfOpn);

    I'm not going to put the whole source code for the Bar_Rating_WPF user control here as 1. it came from you (Telerik) and 2. it's quite lengthy.

    Thank You
    JB

  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 17 Apr 2012 Link to this post

    Hello John,

    You can bind the ItemsSource of the RadRating control to a list of business objects which number will determine the the number of Ratingitems generated in the control. I am not sure if this is what you have in mind, but I created a sample application demonstrating such an approach. Please have a look at it and let me know if it helps or if I've missed something.

    Regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Ramjet
    Ramjet avatar
    51 posts
    Member since:
    Jul 2009

    Posted 17 Apr 2012 Link to this post

    Your demo was quite helpful. I changed the names of the model and viewmodel added some XML commenting but none of that is your concern. What I still can't figure out is how to get the value. So it is bound to the ViewModel to get it's values...cool but how do I get my values back? I see the value property and according to your docs that's what I need to get the selected rating value but it isn't showing for me?? Do I need to have my bar class inherit from your rating class so value is an option?
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 20 Apr 2012 Link to this post

    Hello Ramjet,

    You have a few options for getting the Value property.
    • You can change the BarRatingControl implementation so that it derives from the RadRating control instead of using it in its Content. This would expose all properties of the RadRating in the BarRatingControl.
    • Or you can create a new property in the BarRatingControl class and set its value based on the RadRating.Value changes. For example you can set the BarRatingControl new property value in the RadRating.ValueChanged event so that it is synchronized with the RadRating.Value
    • Or you can simply go with a databinding approach and introduce a RatingValue business property in the ViewModel. And you can bind the RadRating.Value to this business property and in your solution keep track of the business property instead of trying to access the RadRating.Value property directly. I modified my solution to demonstrate this approach.

    I hope this information will help you, but please let me know if I can help with anything else.

    Greetings,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Legoless
    Legoless avatar
    9 posts
    Member since:
    Mar 2012

    Posted 26 May 2012 Link to this post

    Tina, this example has been very helpful and I can finally create this Bar control. But I am wondering, in the demos you provide, there is a sample bar rating control, using the Bar_Rating_WPF or Bar_Rating_SL class. Can you use this in XAML with directly binding the item value and item count? If not, this is a suggestion for next releases. :)

    Thanks,

    Dal
  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 30 May 2012 Link to this post

    Hello Dal,

    Thank you for this feedback. We will defiantly have it in mind next time we're updating the RadRating demo solutions.

    Kind regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
UI for WPF is Visual Studio 2017 Ready