Friday, January 9, 2009

Weird Silverlight Bug!

Ok. This is a weird one. It had been causing problems in one of my apps for a very long time, and it was making me very frustrated... so I decided to hunt this one down. Anyway.. Last night, I figured it out.

Tablet Pc + Listboxes inside Tab Panels = CRASH!

 

This doesn't make too much sense, so let me explain. Listboxes work great in Silverlight. Tab controls work great as well. If you have a listbox in one of the TabPanels it works great as well. If you do this in a Tablet PC (Vista... XP works fine... Go figure!), things are not so good. I built this little app just to verify my find. It consists of a simple TabControl with two tabs. The first tab has a listbox with three items. the second tab has a button.

<UserControl x:Class="TestSlTabletPcBug.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tools="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls">
<
Grid x:Name="LayoutRoot" Background="White">
<
tools:TabControl Height="300" Width="500">
<
tools:TabItem Header="list">
<
ListBox>
<
ListBoxItem Content="1"/>
<
ListBoxItem Content="2"/>
<
ListBoxItem Content="3"/>
</
ListBox>
</
tools:TabItem>
<
tools:TabItem Header="button">
<
Button Content="hi"/>
</
tools:TabItem>
</
tools:TabControl>

</
Grid>
</
UserControl>



image



I do not have a tablet pc, but I do have a Tooya tablet. When this tablet is not plugged in, the application works fine. I can select any item in the listbox and switch between tabs. As soon as I plug my tablet in it doesn't behave as nicely. If there is any item on the listbox, I can't switch tabs. If I do, the application crashes and IE shuts down. Weird!



The workaround....



My workaround was easy... unplug the Tooya tablet and then it worked fine. If you are running on an actual Tablet Pc, simply go to the list of services and stop the Tablet Pc Input Service. Once this is stopped, the application should work fine.



Well... there it is. Hopefully this will save some of you some frustration.

No comments:

Post a Comment