Windows Phone 7 CTP Refresh and InputScope#

If you haven’t heard the Windows Phone 7 CTP April Refresh has been released.  Prepping for my Toronto CodeCamp Session tomorrow I found an issue with setting an InputScope to TextBox.  I am basically doing the same demo Mike Harsh did at MIX10 where all InputScopeNameValues were used to populate a ListBox and then dynamically change the InputScope on a TextBox.

Pre April CTP you could use the following code

textBox1.InputScope = new System.Windows.Input.InputScope() { Names = new InputScopeName() { NameValue = InputScopeNameValue.AddressCity} };

with the April CTP for Windows Phone 7 this breaks now and gives an error of  “Property or indexer 'Names' cannot be assigned to -- it is read only”

Don’t know if it’s a bug or not but there is an alternative as follows.

textBox1.InputScope = new System.Windows.Input.InputScope() ;
textBox1.InputScope.Names.Clear();
InputScopeName isn = new InputScopeName() { NameValue = InputScopeNameValue.AddressCity };
textBox1.InputScope.Names.Add(isn);

Peter Foot also mentioned that you can use XAML to make this happen:

<TextBox Height="32" HorizontalAlignment="Left" Margin="324,70,0,0"
Name="textBox1" Text="TextBox" VerticalAlignment="Top" Width="137" InputScope="Text" />

and then dynamically set it with the following:

((InputScopeName)textBox1.InputScope.Names[0]).NameValue = val;

This is expected with CTPs, just wish it didn’t happen the day before a presentation!


Friday, April 30, 2010 11:21:17 PM (Eastern Daylight Time, UTC-04:00) #    Comments [0]  |  Trackback

 

Comments are closed.
All content © 2012, Mark Arteaga
On this page
Related Sites
Archives
Sitemap
Disclaimer

Powered by: newtelligence dasBlog 1.9.7174.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts