|
-
November 15th, 2009, 12:40 AM
#1
Databinding with multiple control
Hello,
I've come across a weird problem. I've tried a lot of possibilities and still doesn't have the result I want. So, to make it simple, I've got 3 values I want to bind together using controls. From my point of view, this should be really simple and straightforward.
Here a more complete explanation:
Code:
var textBox = new TextBox(...);
var trackBar = new TrackBar(...);
var myClass = new MyClass(...); // Implements INotifyPropertyChanged and calls the delegate in the set.
// looks like this one works perfectly fine.
textBox.DataBindings.Add("Text", trackBar, "Value");
// for a reason I don't understand if I replace the previous line by that it doesn't works as well:
// trackBar.DataBindings.Add("Value", textBox., "Text");
// after that I do another binding:
trackBar.DataBindings.Add("Value", myClass, "myField");
// => This works only in one direction (update are only done when myField is change and not the other way around.)
So, I've got many question and I probably don't understand how it works, but the doc I've found is quite lacking on the subject. So, to be short:
1. Is it the right way to do that kind of thing? Or is there some kind of "DataBindingCollection"
2. If it's ok, why half of the time, it doesn't work. (see line in comment)
3. It's kind of annoying that there is an exception if you try to bind more than value to the same key. Is there a design reason?
thanks in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|