In my XAML, I have the following stackpanel containing a checkboxes for each weekday:
<StackPanel>
<CheckBox>Monday</CheckBox>
<CheckBox>Tuesday</CheckBox>
<CheckBox>Wednesday</CheckBox>
<CheckBox>Thursday</CheckBox>
<CheckBox>Friday</CheckBox>
<CheckBox>Saturday</CheckBox>
<CheckBox>Sunday</CheckBox>
</StackPanel>
In my code-behind, I have a class instance containing the field: List<DaysOfTheWeek> TriggerDays.
Whenever the user clicks a checkbox, I would like the TriggerDays field to update accordingly (i.e. either add or remove the user choice). Or when the field changes from somewhere else in the program, the correct checkboxes should either check or uncheck.
I achieved the wanted results by adding a unique field for each weekday to the class, i.e public bool MondayChecked, public bool ThuesdayChecked, but this is obviously a super-sloppy solution and not scalable.
I suspect that the solution lies in using some kind of conversion. However, I was not able to make sense of the Microsoft documentation for IValueConverter (I am new to XAML and WPF in general).
Thanks in advance for the help!