I spent a few hours on a 90-something KDX 250 (it was a 250 if I remember correctly). A majority of my riding was in the sand. I wouldn't say it is a great trail bike, especially when compared to a 4 stroke of similar displacement. It would depend on the type of riding...
Sand washes were a pain; we were riding in the Page, Az/Big Water, Ut area, zigzagging around. It was typical 2-stroke, nothing, nothing, then you get it on the pipe and it explodes with power, the rearend getting loose. Being in the sand would just choke it unless you revved. It had next to no power on the bottom. I felt like a jackass being the oddball in a group of 4 strokes. Everyone else would tractor up a hill or away from a turn, and I had to get a lower gear and wind it up which resulted in relocating a few pounds of sand/rock. Tighter trails it sucked, more open stuff was a blast though. Dunes, open washes, stuff you could be in 3rd gear or higher, the bike shined. It was fast. You just gotta rev it to make power. It may have better manners on harder ground.
It will out handle and out run the XR, but the XR has it beat in the slow stuff. For my XR4, there is absolutely no way I would swap it for a KDX of any size.