App.xaml.csファイルのRootVisual割り当てステートメントを確認して、SilverlightアプリケーションのメインのXAMLファイルを見つけます。
private void Application_Startup(object sender, StartupEventArgs e)
{
**this.RootVisual = new MainPage();**
}
デフォルトでは、MainPage.xaml.csがUserControl
アプリケーションの起動時に最初に読み込まれます。
UserControl.MouseLeftButtonDown
MainPageコンストラクターのイベントにイベントハンドラーをアタッチします
public MainPage()
{
InitializeComponent();
**this.MouseLeftButtonDown += MainPage_MouseLeftButtonDown;**
}
イベントハンドラーで、 Html Bridgeを使用してjavascriptメソッド「refocusScreen」を呼び出します(このメソッドを実装して画面のフォーカスを変更する必要があります)。
void MainPage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// About [Invoke][2] method
**HtmlPage.Document.Invoke("refocusScreen");**
// detach event handler so that this won't call the JS method everytime the Mouse left button goes down.
this.MouseLeftButtonDown -= MainPage_MouseLeftButtonDown;
}