September 28, 2008

Sebastian

Migrating Silverlight TextBox to Version 2 RC0

filed under: playing Lego — Sebastian @ 3:00 pm

Like many other folks in these days we also had to migrate our Silverlight code from Version 2 Beta 2 to Version 2 RC0. Fortunately almost none of the API changes affected our code, except an undocumented change to the predefined user control TextBox. We used to trigger the MouseLeftButtonDown event successfully until RC0. After the RC0 update the event didn’t fire and no error was thrown.

Additionally the TextBox was somehow locked whenever its visibility attribute was set collapsed and visible again: the user could not change the text within the TextBox any longer.

Here is our workaround:

  • Replace the MouseLeftButtonDown event by a GotFocus event.
  • Remove the TextBox from the children collection of its parent element and add it again.

The old code:

XAML:

<TextBox
x:Name="MessageTextBox" Text="(attach a message)"
MouseLeftButtonDown="MessageTextBox_MouseLeftButtonDown"
Height="80" Width="280" FontSize="14" Cursor="IBeam"
AcceptsReturn="True" VerticalScrollBarVisibility="Auto"
Style="{StaticResource TextBoxMessage}"/>

The new code:

XAML:

<TextBox
x:Name="MessageTextBox" Text="(attach a message)"
GotFocus="MessageTextBox_GotFocus"
Height="80" Width="280" FontSize="14" Cursor="IBeam"
AcceptsReturn="True" VerticalScrollBarVisibility="Auto"
Style="{StaticResource TextBoxMessage}"/>

C#:

ConfirmationDialog.Children.Remove(MessageTextBox);
ConfirmationDialog.Children.Add(MessageTextBox);

related posts

  • No Related Post

no comments »

no comments yet.

rss feed for comments on this post. trackBack url

leave a comment

Additional comments powered by BackType


© Copyright SnipClip | www.snipclip.com
© Copyright Blender Foundation | www.bigbuckbunny.org
Facebook is a registered Trademark of Facebook Inc. | www.facebook.com
community:
news
blog
facebook
downloads
usage:
terms of use
privacy policy
imprint
feedback
infos for:
producers
communities
investors
press
company:
about
contact
partners
jobs