Posting in the hope this helps others with what seems to be a fairly common fault.
2013 XF Sportbrake....
My hazard lights were turning themselves on randomly. Initially, I was able to pull over, switch off and turn them off using the dashboard switch but it developed into a fault where they would remain on despite trying to use the switch to turn them off. The only thing left for me to do was to disconnect the battery and leave it. They ususally remained off for a few minutes when I reconnected the battery again but would inevitably come on a gain at some stage of my journey.
I had recently had the rear fusebox replaced as a result of historic water ingress causing some connection errors, so I knew it wasn't that.
A visit to Preston Jag Centre (Recommended for Lancashire dwellers) was again required and after just an hour of investigation they were able to identify the fault to be a mysteriously damaged wiring connector in the offside 'D' Post. Apparently it was a tricky job to get their hand up into the wiring loom which ran up into the roof lining after removing the inner trim, but it now seems to have done the trick and I'm back in love with my Jag.