How To Make Sure the Silverlight App Gets Keyboard focus

The following sample shows you how to force focus to the silverlight control when your aspx page comes up.  In the body tag add the following javascript (where XAML1 is the ID of your Silverlight control

<body onload="document.getElementById('XAML1').focus()" style="height:100%;margin:0;">

Your Silverlight control tag should already look something like this.

<asp:Silverlight ID="XAML1" runat="server" Source="~/ClientBin/MySilverlightApp.xap" MinimumVersion="2.0.30523" Width="100%" Height="100%" />

Ebook Download
View all
Learn
View all