To begin the week, I will be fixing bug in Service class by refactor small changes on implementation. My objective is changing Read() to Get() on certain variable in update method. As this variable only has existing Read function, I then added Collection<Variables> GetVariables in Repository class. Hence, I change ReadVariables() to GetVariables() for update/edit/delete and any function that will make changes on the value of this variable.
In the progress, we bump into an issue, where we still able to input despite in detail view mode. This is a serious bug, as any changes would be updated/saved when ReadyToPick is triggered. Thus, we came up with a idea after discussing the issue. I need to set all input/controls to IsReadOnly and disable them. In order to do that, I need to alter code in DetailView XAML class and add new properties in DetailViewModel class.
As an alternative, I add IsEnabled = "{Binding IsControlEnabled}" and IsReadOnly= "{Binding IsControlReadOnly}" for relevant controls. While in DetailViewModel, I introduced two properties which is IsControlEnabled with default value true and IsControlReadOnly with default value false. I then perform logic of IsControlEnabled = false and IsControlReadOnly = true under view mode, making user unable to make changes on all controls.
However, there is a grid data textbox, buttons and combo box that is not set to disable & read only simply by using above method. It happens that I need to link it to ancestor of data grid such as below:i) IsEnabled="{Binding DataContext.IsControlEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"
ii) IsReadOnly="{Binding DataContext.IsControlReadOnly, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"
After code is altered, system user could use ReadyToPick without able to edit them in view mode. (In edit mode, user able to make changes but ReadyToPick button is disable). Hence, the bug fixed.
