troubleshooting Question

ObservableCollection bound to User Control, need to get bound data in code behind

Avatar of wint100
wint100Flag for United Kingdom of Great Britain and Northern Ireland asked on
.NET ProgrammingMicrosoft Development
13 Comments3 Solutions783 ViewsLast Modified:
I'm developing a SL4 application that alternates between different usercontrols on timer_tick event.

Previously I was doing it the old way of passing parameters to the usercontrol. I've now stored the data I need in an ObservableCollection, which I've bound to the USerControl's datacontext. The main reason for this change being that I need the field on the UserControl fields to update automatically as the data in the collection changes due to WCF calls etc.. (Please correct me if I'm doing things wrong here..)

There are two things I need to do if possible:

1) The collection holds decimal types, and I'd like to keep it this way, but I need to add a suffix to the TextBlock that is bound to the decimal. So, the value of the decimal is 202, I need to add "kWh" to the TextBlock. If not, I'll have to look at the collection holding strings.

2 I need to GET some of the data from the DataContext in code behind of the UserControl, to do some calcs before I then use on the UI. Is this possible? Can I Get data from the datacontext in any way?

Thanks
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 3 Answers and 13 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros