DataGrid: Selection stops working when the control is detached and right away attached to the visual tree
When the DataGrid is placed inside a Panel (for example Grid) and after that is removed from that panel and is placed in another one the selection stops working. The issue is caused by the inaccurate order of the thrown Unloaded and Loaded events which the control relies on.