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:
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
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
5 Answers, 1 is accepted
0
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
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 >>
0
Ramjet
Top achievements
Rank 1
answered on 17 Apr 2012, 09:48 PM
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?
0
Hello Ramjet,
You have a few options for getting the Value property.
Tina Stancheva
the Telerik team
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 >>
0
Legoless
Top achievements
Rank 1
answered on 26 May 2012, 02:06 PM
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
Thanks,
Dal
0
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
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 >>