Tuesday, July 28, 2009

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

<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: ,

Sunday, July 5, 2009

Double quotes problem in Windows 7

EDIT: Due to big popularity of this post, let me put the solution on top:

If you have a problem with quotes in Windows 7, try to switch the keyboard layout from "United States - International" to "US"
After changing the keyboard layout, you may need to restart your programs or the computer.

ORIGINAL POST:

After installing Windows 7 and Visual Studio 2008, I discovered the following behavior in the code editor:
Pressing the double-quote (") key once would have no effect.
Pressing any key after that would produce both the double quote character and the next character.

The problem was not caused by Visual Studio, but by regional settings - I solved it by switching from "United States - International" to "US" keyboard layout.

Labels: , ,