Model-View-ViewModel: Structuring UI Code
Your user interface started off clean, but now the code is a rat's nest of special cases, and no two parts of the UI can agree on what the data they should be displaying is?
Maybe you need MVVM, or Model-View-Viewmodel.
MVVM is an application design pattern often used in user‑interface programming. It provides a structure for organising applications that is particularly useful when multiple views need access to the same underlying data.