I have a problem with a method. I have checkboxes to change the value of variables to true / false.
My variables Prise1, Prise2, Prise3 and Prise4 on one side, and on the other side on the 7 days of the week.
I have to complete a request that is made in relation to the selected days. For example:
On the screenshot, I would like to modify the information about:
- Tuesday, Wednesday of "prise1"
- nothin on "prise2"
- on Friday and Sunday of "prise3"
- Thursday of "duration"
I thought of a 2D table that I could go through to check if the values are true / false, but I don't really know how to do it.
Edit : Did i miss something ? Binding doesn't work, when i check i'm not going into the "set".
public class WeekValues : ObservableObject
{
public bool Monday { get; set; }
public bool Tuesday { get; set; }
public bool Wednesday { get; set; }
public bool Thursday { get; set; }
public bool Friday { get; set; }
public bool Saturday { get; set; }
public bool Sunday { get; set; }
}
For the viewModel :
private WeekValues _Prise1;
public WeekValues Prise1
{
get
{
return _Prise1;
}
set
{
if (value != _Prise1)
{
_Prise1 = value;
RaisePropertyChanged(nameof(Prise1));
}
}
}
private WeekValues _Prise2;
public WeekValues Prise2
{
get
{
return _Prise2;
}
set
{
if (value != _Prise2)
{
_Prise2 = value;
RaisePropertyChanged(nameof(Prise2));
}
}
}
and WPF :
<StackPanel HorizontalAlignment="Center" Grid.Row="1" Grid.Column="2">
<CheckBox Margin="0,9,0,5" IsChecked="{Binding Prise1}"></CheckBox>
<CheckBox Margin="0,10,0,5" IsChecked="{Binding Prise2.Monday}"></CheckBox>
<CheckBox Margin="0,10,0,5"></CheckBox>
<CheckBox Margin="0,9,0,0"></CheckBox>
</StackPanel>
<Label Grid.Row="0" Grid.Column="3" HorizontalAlignment="Center" FontWeight="Bold">M</Label>
<StackPanel HorizontalAlignment="Center" Grid.Row="1" Grid.Column="3">
<CheckBox Margin="0,9,0,5" IsChecked="{Binding Prise1.Tuesday}"></CheckBox>
<CheckBox Margin="0,10,0,5" IsChecked="{Binding Prise2.Tuesday}"></CheckBox>
<CheckBox Margin="0,10,0,5"></CheckBox>
<CheckBox Margin="0,9,0,0"></CheckBox>
</StackPanel>
Thank you in advance