First - yes I'm very new to C#, .net, and the rest of this object oriented stuff. I did a decent amount of stuff under old ANSI-C...
I'd like to include some controls in a GroupBox as part of my class. I probably could just make sure I always handle changes in data values and update the controls, I can demonstrate that this works.
I also know that there is a concept of "data-binding", and have built some small Access databases and bound them to DataGridView controls successfully.
What I'd like to do is bind the value of the class.property to the class.control.value so that the two are always synchronized. Is that possible? What keywords should I be searching under? I hate just "asking" for help, but any direction would be very helpful.
One thought I'm having even as I type this - Can I just make the control.value the effective storage for the class.property value? I could create appropriate {get; set;} methods that work directly on the control. Would this be considered "good-practice"? or is there some better practice I should learn?
Again, thanks in advance for any advice.
Loading
Sam HobbsPosted Sep 24, 2010, 6:37 AM
Are you sure you would use a GroupBox in that manner in a Windows API program or a C++ program that uses MFC? I don't think so and if not then asking how to use a GroupBox might get you misinformation. I also don't understand "GroupBox as part of my class"; I think that would also not be done in a Windows API applicatin but perhaps I misunderstand what you are doing.
Mike GoldPosted Sep 23, 2010, 2:57 PM
1) Create a Class with properties and in the set property use a PropertyChanged call to signal a notify property changed. (Also you'll need to inherit your class from INotifyPropertyChanged)
2) In your Xaml add the control property with {Binding PropertyName, Mode="TwoWay"}
If you are working with Windows Forms, this is more difficult because a lot of controls don't work correctly with the built in databinding that Microsoft tries to provide for WinForm Controls.
Not sure which you are using, but if you have the ability to switch, develop your app using WPF and you should be good to go.
-Mike