X-UA-Compatible
(either meta element or HTTP response header) with IE=edge
value reliably prevents user from switching to compatibility mode by clicking button at the right of location bar — since the button is not shown at all when X-UA-Compatible
with IE=edge
value is present.
Ability to switch modes via developer tools (opening via F12 key) is not an issue — this is development feature which state does not persist after browser is restarted so is totally safe and is not something to care about.
However, if page works incorrectly in IE8 compatibility mode, then it very likely works incorrectly in real IE8 too. So if support for IE8 is important for you, you should fix issues related to IE8 itself, not to compatibility-mode feature.