I have noticed a strange behaviour of TextBox while BorderThickness property is set to 1 – the focus causes the border to change the color (to something like white).
However, if I set the border thickness to something different than 1, say .99 or 1.01 the problem disappears.
Is it the bug in WPF? Or is it intended?
This is the default behavior of the Aero style for TextBoxes. To disable it you would need to restyle the TextBox. You can take the default styles from here (see Download Sample).
In the default Style for TextBoxBase (which TextBox is based on), you will see it uses a ListBoxChrome. This element is defined in the Presentation.Aero assembly and is responsible for rendering the “focused” look. You can simply remove the RenderFocus setting and possibly the RenderMouseOver, or replace it with a Border.
Then you’d want to include that in your application resources.
If you look at the ListBoxChrome class in Reflector (specifically the OnRender method), you can see it will only render the focused look if it’s BorderThickness is “1,1,1,1”.