Change Node style dynamically

I was wondering if there is a way to change Node style dynamically.
For example, After dragging and dropping a node on the diagram which comes with default style. If i move the node inside a container, i want to apply a different style. Can we do this from code?
I have all my styles defined as data template under resources.

Yes, if you have set up the different DataTemplates in the Diagram.NodeTemplateDictionary, it’s just a matter of changing the node data’s Category property.

Thank you for quick reply. I’m using Category to do some validations. Is there any other way to change the style without changing the category property?

If you don't want to use the Category property for that purpose, add your own property for that information.

Either replace your existing uses of Category with your new property, or have the model/diagram use your new property by setting model.NodeCategoryPath to your new property’s name.

I might be asking a stupid question but do you have any code sample?