How can I create a binding to a sub-property of a specific element in a list?
I've created a class that exposes an IList property:
public IList<VideoChannel> VideoChannels {
get {
const int NumVideoChannels = 4;
return (new List<VideoChannel>(NumVideoChannels) {
new VideoChannel("Channel 1") {
VideoActive = !_rawData[Main][0x04].BitIsSet(0),
OutOfRange = !_rawData[Main][0x05].BitIsSet(0) },
new VideoChannel("Channel 2") {
VideoActive = !_rawData[Main][0x04].BitIsSet(1),
OutOfRange = !_rawData[Main][0x05].BitIsSet(1) },
new VideoChannel("Channel 3") {
VideoActive = !_rawData[Main][0x04].BitIsSet(2),
OutOfRange = !_rawData[Main][0x05].BitIsSet(2) },
new VideoChannel("Channel 4") {
VideoActive = !_rawData[Main][0x04].BitIsSet(3),
OutOfRange = !_rawData[Main][0x05].BitIsSet(3) },
}).AsReadOnly();
}
set { ;}
}
I've also created an 'LED' UserControl with a single boolean property ('LedOn') that determines the colour of the led.
I want to create 8 'LED' controls, each of which is bound to a specific 'VideoActive' or 'OutOfRange' property in the IList above.
This doesn't seem to work:
ledVideoActiveChannel1.DataBindings.Add("LedOn", _myDevice, "VideoChannels[0].VideoActive");
ledOutOfRangeChannel1.DataBindings.Add("LedOn", _myDevice, "VideoChannels[0].OutOfRange");
The error is "Child list for field VideoChannels[0] cannot be created."
I'm relatively new to C# and OOP in general, so forgive me if this is a trivial question.
Thanks!