Missing rectangle focus when navigating to WPF control in codebehind via both Keyboard.Focus() and C

Hi All,

I have been writting an WPF application which allows enduser navigating to controls which being bound to an invalid data by clicking on buttons named “Goto Prev Err” and “Goto Next Err”. The implementation was written in codebehind by
calling Focus method. However the rectangle focus is invisible when a control gets focus via either one of two upon buttons. I tried moving the focus around controls in my view via pressing the “TAB” and I could see that rectangle.

Do you guys have any ideas about that ??? I do appreciate.

 

var control2Focus = _controls.FirstOrDefault(item => this.IsErrorFile(item) && callback.Invoke((int)item.Key));

if (control2Focus != null) {
    _currErrPos = (int)control2Focus.Key;
    // (control2Focus.Value as Control).Focus();
    Keyboard.Focus(control2Focus.Value as Control);

}