Lets say I have an application which comprises one window. Inside the window is a tabcontrol, with three tabitems. Inside each tabitem is a usercontrol.
In one tab I have Add color. In the next tab I have add Fruit. In the third tab I have relationships, where the user can add links between the fruit and the colors. This relationship is displayed in a listbox like:
Apple > Red
Pear > Green
Below this in the same tab I have missing fruits listbox and a missing colors listbox... i.e. fruits or colors that have been added but not linked in the relationship. I should explain that this data is all stored in three seperate textfiles, fruits.txt, colors.txt and relationships.txt.
The problem I have is as follows. At the moment the populating of the listboxes etc is on Usercontrol_loaded event. It doesn't matter for fruit/colors, as after the add button is clicked, the list reloads. The problem is in the relationship screen.
Say the user runs the program, and clicks on the relationship tab to see what is linked. We'll say that the above example was already in the textfile. So that relationship shows up - and no missing fruits. The user then clicks the fruit tab and adds a fruit and then the color tab and adds a color. Then moves to the relationship tab. The usercontrol_loaded event has already occured, so these two new additions do not show in the listboxes.
If I move the code to GotFocus event, the user can't make selection in any listbox because it is constantly loading, as clicking fires the event.
Is there any other event or way I could have this refresh JUST when the tab has been "switched to", other than providing a refresh button?
Thanks for reading.
...
Edit 1: If I databind to a list of missing fruits which I build in the codebehind, I still have the same problem. I have to reload this list everytime they go jump off this tab and come back to it (because potentially they've added a fruit or a color, which is now missing).