Xanax can be used to treat dementia patients in that Xanax helps anxiety and dementia patients often have anxiety. People with dementia often have a very difficult time figuring out what is going on around them. Anxiety is an understandable reaction for anyone in a situation they don't understand.
Since dementia patients are often in that state all day long, many of them are treated for their anxiety. Xanax isn't likely to be used for long-term treatment, as it is addictive, but other drugs for anxiety exist for that purpose. And Xanax is a very good drug for occasional use. I would think Xanax can be used to treat dementia patients under some conditions.