Monthly Archives: March 2010

Getting Blur And DropShadow to work in the Windows Phone Emulator

I’ve noticed a few questions in the forums around why the Blur and DropShadow effects aren’t showing up in the Windows Phone 7 Series emulator and the simple answer is you have to set CacheMode to BitmapCache.

<TextBlock Text="DropShadow" Foreground="Black" FontSize="48" CacheMode="BitmapCache">
	<TextBlock.Effect>
		<DropShadowEffect/>
	</TextBlock.Effect>
</TextBlock>
<TextBlock Text="Blur" Foreground="Black" FontSize="48" CacheMode="BitmapCache">
	<TextBlock.Effect>
    	<BlurEffect/>
	</TextBlock.Effect>
</TextBlock>

We are working on setting this automatically so you don’t have to scratch your head each time you apply an effect and wonder why it looks fine on the design surface yet doesn’t show up in the emulator.

UPDATE [7/20/2011] – I was looking through my blog and realized this needs to be updated. For anyone still looking for this information all the effects such as Blur & DropShadow were intentionally disabled from the product for both 7.0 and the upcoming Mango.  The performance hit that applications took from using these effects put too much of a strain on the system and it was decided that if we couldn’t deliver a perfomant feature we would disable until such a time as we could.

Changing the Onscreen Keyboard (SIP) in Silverlight for Windows Phone 7 (WP7) using InputScope

Given that the main way users enter text in your Windows Phone 7 Series application is via a tiny onscreen keyboard (a “Software Input Panel” or SIP) it’s in everyone’s best interest to make sure the right keys are available to the user when they need them.

A good example is when you go to enter a PIN number you really only want to see number-related keys, when composing a SMS you’d like a quick way to insert an emoticon and if writing something longer you probably want auto-correction and replacement suggestions. The good news for Windows Phone developers is you can control which SIP layout is used and which auto-correct settings are enabled by setting the InputScope property of your TextBox.

The concept of InputScope isn’t new to XAML by the way, this concept already exists in WPF and was a nice fit with the native SIP behavior so if you’ve used InputScope before you should be right at home.

Setting InputScope

There are really three ways to set InputScope, two of which are cumbersome yet provide Intellisense and a third that is easy but requires you to know exactly which InputScope you’re after.

Via XAML

Doing it this way you’ll get full Intellisense yet it’s a lot of work to set a simple property:

<TextBox>
    <TextBox.InputScope>
        <InputScope>
            <InputScopeName NameValue="Text" />
        </InputScope>
    </TextBox.InputScope>
</TextBox>

Via Code

If you’re more the code-behind sort here it is in C#:

textBox1.InputScope = new InputScope()
{
    Names = { new InputScopeName() { NameValue = InputScopeNameValue.Text } }
};

Via XAML with a TypeConvertor

Remember how in high school they’d always teach you the hard way before showing you the easy version? Guilty as charged. If you already know the exact InputScopeNameValue you want to use, for example ‘Text’, then you can take advantage of the built-in TypeConvertor that is already wired up to the property and write this much easier XAML:

<TextBox InputScope="Text" />

InputScope Example Application

When we were bringing InputScopes from WPF to Silverlight for Windows Phone I wrote a quick app to show all the available InputScopes and automatically set the selected one on a TextBox. This gives you a feel for how many there are and what layout comes up when set. Here is what it looks like along with a link to the source:

Download the source.

InputScope Sample Application

Common InputScopes

Now that you know how to set them here are some of the more useful InputScopes:

Default

This is the default InputScope when no input scope is specified. Auto-capitalize first letter of sentence. The app can show app specific text suggestions.

Layout: Standard QWERTY layout.

Default InputScope
Number

When all you’re looking for is basic number entry. All features like auto-capitalize are turned off.

Layout: the first symbol page of the standard QWERTY layout.

Number InputScope
Text

When the user is typing standard text and can benefit from the full range of typing intelligence features:

  • Text suggestions (while typing and when tapping on a word)
  • Auto-correction
  • Auto-Apostrophe (English)
  • Auto-Accent
  • Auto-capitalize first letter of sentence

Layout: Text layout and access to letters, numbers, symbols and ASCII based emoticons + text suggestions.

Example fields: email subject and body, OneNote notes, appointment subject and notes, Word document, etc.

Text InputScope
Chat

The user is expected to type text using standard words as well as slang and abbreviations and can benefit from some of the typing intelligence features:

  • Text suggestions (while typing and when tapping on a word)
  • Auto-Apostrophe (English)
  • Auto-Accent
  • Auto-capitalize first letter of sentence

Layout: Chat layout and access to letters, numbers, symbols and rich MSN like emoticons + text suggestions.

Example fields: SMS, IM, Communicator, Twitter client, Facebook client, etc.

Chat InputScope
Url

The user is expected to type a URL. All auto-correct features are turned off.

Layout: Web layout with “.com” and “go” key

Url InputScope

For a complete list of InputScopes supported in Windows Phone 7 check out this MSDN link: InputScopeNameValue Enumeration.

In Conclusion

As you’re writing your applications don’t forget about InputScope, it’ll give it just that much more polish and can really make a difference in usability.

Slides + Code + Video from ‘An Introduction to Developing Applications for Microsoft Silverlight’ from MIX10

I promised someone at the end of my talk that I’d post my code and slides and while
I’m lagging a little behind I’ve finally bundled them up and made them available
for download here:

Slides + Code

Also, as a small note I’m slowly working this blog over to have a “Windows Phone
7 Design Series” look and feel, not sure how well the dark background and light
text is going to carry over or how well my design kung fu will stack up but here
goes.

UPDATE #1: I’m also including the actual session itself here for
your viewing pleasure.  You can either watch it below or
directly on the MIX website
.

UPDATE #2: Several people have asked me for sample code to the
solution that has a Windows Phone and Silverlight desktop application both consuming
the same Class Library.  Well, here it is for your downloading pleasure.

width="640" height="360">
Get Microsoft Silverlight

An Introduction to Developing Applications for Microsoft Silverlight @ MIX10

A quick heads up for anyone that saw my upcoming talk at MIX10. I’m super excited (why do normal excited when you can be *super* excited!) to show everyone the basics of Silverlight so people can begin creating rockstar web and Windows Phone applications. Speaking of the basics I want to share for anyone that did a Bing search wondering who this Shawn Oster fellow is and what his talk is really about.

My talk, An Introduction to Developing Applications for Microsoft Silverlight, really is an introduction, a 101. Maybe you are a HTML/JavaScript ninja, perhaps you’re just starting out, maybe you decided hand tuning assembly had lost its luster, whatever reason if you’re a blank Silverlight slate then this is the talk for you. On the other hand if you know about this crazy concept called XAML or have the basics of wiring up event handlers and doing a little data binding then this talk is definitely not for you.

If you’re hoping for some Windows Phone love then you don’t have to wait too much longer, Mike Harsh and Peter Torr lay down all the Windows Phone specific goods for you in the talks following mine. Think of my talk as a primer for those that need a quick intro to some of the concepts they’ll be seeing later.

MIX is an awesome, information-packed developer/designer lovefest and I’d hate for you to miss out on another track having to sit through 101 information.