Focus a Silverlight control on startup
I found two solutions to this problem on the web and neither of them worked for me. I finally combined both of them to make it work:
In the aspx page, include
And then in Page.cs class as a response to Loaded event:
In the aspx page, include
<script type="text/javascript">
window.onload = function()
{
setTimeout(function() { document.getElementById('Xaml1').focus(); }, 1);
}
</script>
And then in Page.cs class as a response to Loaded event:
Dispatcher.BeginInvoke(delegate{myControl.Focus();});
Labels: focus, silverlight