I'm in the process of rewriting a small application from console mode to a GUI mode.
The input is a file with log data from a measuring device:
...
00029;00044;00076;00044;00021
00309;00032;00037;00000;65535
00013;00016;00008;00007;00005
...
Each row of data represents 5 counters which summarize the range in which the measure fell, i.e. first column is "<40%", 2nd column is "[40-50[", and so on...
First row as example:
29 counts below 40% | 44 counts between 40% and 60% | 76 counts between 60% and 80%
44 counts between 80% and 90% | 21 counts between 90% and 100%
In the console application I used an array of integers to store each data row, putting each row array in a list. So far, so good... The application then used a for-loop to print out the values with descriptions to the console.
My problem: I wanted to create a GUI with WPF and apply databinding.
But I have a conceptual issue with how to create the data binding to the arrays of integers and visual elements.
I have not had problems with data binding to single properties. The challenge is due to the arrays.
I think I should create a class like this (could also be used as a ViewModel):
public class CounterRecords
{
public List<CounterRecord> DataRecords { get; set; }
}
But how should I go about the CounterRecord
class?
What's a clean / clear implementation of this object that I can bind to?
public class CounterRecord
{
public int Range40 { get; set; }
public int Range40_60 { get; set; }
public int Range60_80 { get; set; }
public int Range80_90 { get; set; }
public int Range90_100 { get; set; }
}
ObservableCollection
?