Hi I'm not able to set focus on parent of control. I have a control which is placed on canvas. If I click that control I need to set focus on canvas in order to handle some keyboard events. However despite the fact that I was trying to set focus like that
protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
{
base.OnPreviewMouseDown(e);
Canvas designer = VisualTreeHelper.GetParent(this) as Canvas;
designer.Focus() ;//this doesn't work
Keyboard.Focus(designer); //this also doesn't work
}
Keyboard events which are attached to canvas don't fire.