As was mentioned in comments for the question, using MVVM and changing controls in code behind is a bad idea.
Your behavior should define a boolean attached property, let's call it IsInEditMode
. Then, instead of setting the template directly, set the value of the attached property to true
. In your styles/templates add triggers to change templates (or set visibility for parts of the template) depending on the value of IsInEditMode
.
This way you'll have ability to react to all combinations of properties (IsInEditMode && TestProperty
; IsInEditMode && !TestProperty
; etc...)
Also, you'll be able to use the behavior on other controls.