In WPF, how do you set the target of a label so that the access key will set focus on the control inside a ContentControl?
I am using MVVM and so I do not want to add any code to the code behind in order to solve this.
I have already tried setting the path to “Content” and at runtime an exception was thrown because there is no converter for the data type which is set to the content of the ContentControl. If I don’t set the path, then focus is set to the ContentControl itself.
<Label Target="{Binding ElementName=_myContentControl, Path=Content}"/>
Use GotFocus event.
Another solution using the separated class FocusBehavior:
XAML:
This way requires a dll that is called System.Windows.Interactivity and is installed with Expression Blend SDK.