I've got a block of controls I am using multiple times on different tabs. I created a user control in XAML so that I could re-use this block. If I make a aesthetics change to it then it propagates through with ease. Now, I need to initialize the controls in the user control. That's easy enough. However, instead of doing this:
Code:
SegmentControl1.ComboBoxMode.ItemsSource = fc.CameraSettings.Modes;
SegmentControl1.ComboBoxMode.DisplayMemberPath = "Value";
SegmentControl1.ComboBoxMode.SelectedValuePath = "Key";
//1 to 10 ...
SegmentControl10.ComboBoxMode.ItemsSource = fc.CameraSettings.Modes;
SegmentControl10.ComboBoxMode.DisplayMemberPath = "Value";
SegmentControl10.ComboBoxMode.SelectedValuePath = "Key";
I would like to do something similar to this:
Code:
//Loop i from 1 to 10
SegmentControl[i].ComboBoxMode.ItemsSource = fc.CameraSettings.Modes;
SegmentControl[i].ComboBoxMode.DisplayMemberPath = "Value";
SegmentControl[i].ComboBoxMode.SelectedValuePath = "Key";
This would be much more efficient and result in code easier to read.