I have only seen code solutions to this problem. I am looking for a XAML based solution and I am quiet surprised you can't set focus on a UI element in XAML.
I found this old MSDN post: http://social.msdn.microsoft.com/Forums/en/wpf/thread/09dc837d-4485-4966-b45b-266727bbb90c
that had the solution I sought ( this is WPF only I guess )
<Grid FocusManager.FocusedElement="{Binding ElementName=listBox1}">
Is setting focus to a TextBox/ListBox in Silverlight 4 XAML not possible ?
As far as I know, no, there is not a way in XAML to set the focus of an element. You'll have to resort to something like you've referenced. I think an attached behavior (similar to the
FocusManager
) would be the best route.