Search code examples
silverlightsilverlight-2.0

Why am I not getting keyboard input events when in full screen mode?


I am having some problems with the Silverlight full screen mode.

If I switch my application to full screen all the input from the keyboard is not handled. No textbox input, no key down / key up event and probably much more. Here is a sample application that demonstrates this:

Xaml :

<Canvas>

<TextBlock Text="Try some input:" Canvas.Top="10" Width="100"></TextBlock>

<TextBox x:Name="tboxInput" Width="100" Canvas.Top="30"></TextBox>

<Button x:Name="btnFullScreen" Content="Go Full Screen" Canvas.Top="60"></Button>

</Canvas>

Code behind:

public Page() 
{

InitializeComponent();

btnFullScreen.Click += new RoutedEventHandler(btnFullScreen_Click); 
}

void btnFullScreen_Click(object sender, RoutedEventArgs e) 
{

Application.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen; 
if (!Application.Current.Host.Content.IsFullScreen)

btnFullScreen.Content = "Go Full Screen"; 
else

btnFullScreen.Content = "Go Normal Screen"; 
}

It is simple to see that in full screen mode you can't write text in the textbox. Am I doing something wrong here? Is there another way to switch full screen so this will not happen?


Solution

  • This link should help you out: http://silverlight.net/forums/p/11519/36798.aspx

    EDIT

    And this MSDN article gives you a more detailed reason:

    When a Silverlight plug-in is in full-screen mode, it disables most keyboard events. This limitation of keyboard input during full-screen mode is a security feature, and is intended to minimize the possibility of unintended information being entered by a user. In full-screen mode, the only input allowed is through the following keys.

    UP ARROW, DOWN ARROW, LEFT ARROW, RIGHT ARROW, SPACEBAR, TAB, PAGE UP, PAGE DOWN, HOME, END, ENTER