It always shows " This element is already associated with a XamlRoot, it cannot be associated with a different one until it is removed from the previous XamlRoot "
Also its raising error when we set XamlRoot = this.Content.XamlRoot;
Can anybody explain why this behaviour is happening and how could we resolve that ?
I would recommend trying this code and then modifying it to your needs:
But to really answer your question, you'd need to provide your code and more details in your question.