Jaime Rodriguez On Windows Phone, Windows Presentation Foundation, Silverlight and Windows 7
With the Windows Phone (codenamed) Mango beta release, the Windows Phone team thrived to have great documentation and useful learning resources for WP7 developers. I think they did a superb job and given it came after MIX (and we had lots of great video content) the docs have gone unnoticed a bit, so I want to highlight a couple of these resources to make sure developers are getting the most out of these. Today, I will cover the documentation improvements and the new “Mango” training kit. <shortcut> If you rather watch videos, here are two that summarize this post:Luke Nyswonger, lead for Windows Phone online documentation does a video walk through of all the new stuff in the docs.Yours truly does a walk-through of tidy, one of the apps in the training kit. It is a scenario that we use for five labs: sql ce, background agents, tiles, background transfer, and reminders. </shortcut>
New Mango training kit: With the new Windows Phone training kit for Mango release, we did a few things different:
Here are some of the new samples you will find in the training kit:
Great improvements and additions to the documentation The documentation team also did a few things different.
Again, if you want to see a brief video of these changes, Luke will give you a walk through in this video With all the above changes, developers can find every thing easily, they get a very comprehensive (and deep) view into the features, and they can even have fun while doing it. Thanks to the doc teams (and the PMs that reviewed it ) for all this goodness; I am sure I missed some; if you find it, comment on it please (or write your own blog post about it ).
Happy Windows Phone coding! Don’t forget to read the docs.
I hope I am not the only person who did not know this (apologies if that is the case). <context> A few weeks ago while at an event in Finland, my emulator did not detect an orientation change during a demo. Some one suggested I restart the emulator, I did, and it worked (against my instinct). Today, I found out what’s going on. </context> <answer> When you use the Page Up/Page down button, the emulator let’s you toggle the Software Input Panel (SIP) on and off. Also when you use the Pause/Break button the emulator disables the SIP and let’s you enter text via your keyboard. All that works neatly as expected. I use that all the time. The part I did not know is that the emulator does not support orientation changes when the keyboard is enabled. This is all well documented in the keyboard mapping page: http://msdn.microsoft.com/en-us/library/ff754352(v=VS.92).aspx but I did not know. Not sure if it has always been documented and I missed it or it is new; either way, fooled me once.. but not again.. </answer> Happy Windows Phone coding (and don’t forget to read the manual now and then !!)
In my last post, I teased that system tray in Mango is now customizable and data binding friendly On top of that, the SystemTray now has a ProgressIndicator that you can use to replace your PerformantProgressBar and display progress on async operations.
Here is everything you need to know (or everything I know) about ProgressIndicator. It is a DependencyObject so you can data bind to it.. You can use these properties to customize and manage the indicator:
A few small quirks and tips :
The screenshot to the right shows you all of SystemTray’s properties in action. It has a white foreground and green background with 60% opacity, indeterminate progress indicator and (obviously) custom text in the indicator. You can turn everything on and off to see the impact as you tweak each property. It is all data bound; there is no manual setting of any properties. I am running on light theme with orange highlight. You can get the source from my skydrive.
Happy Windows Phone “Mango” coding.
A missing feature from Windows phone 7.0 was the ability to set the Background and Foreground color in the SystemTray. For branded apps (like Facebook) this was a problem cause the tray looked ugly, so most of these apps had to hide it, hiding important notifications (like clock, battery indicator ) from the user..
In Mango, you can finally set Foreground (of type System.Windows.Media.Color ), and Background (type Color too) on SystemTray. I hope that going forward, all apps start setting IsVisible=”true” on the system tray. There is no excuse now for hiding it any more. I just looked at the API and found two other nice surprises:
Of course, there is one more nicety in SystemTray (ProgressIndicator). I will share my code on that in the next post (hopefully tomorrow)..
Happy Windows Phone “Mango” coding!!
if you try using RichTextBox in the recently released Mango Beta tools, you might notice the control does not have a default control template applied to it. [That means when you try to use it, you will see nothing but not get an error either].
This is a known issue for the beta. To get around it, simply apply this current Style to the page (or the App.xaml) for your project .
<Style TargetType="RichTextBox"> <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeNormal}" /> <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}" /> <Setter Property="Background" Value="Transparent" /> <Setter Property="BorderBrush" Value="Transparent" /> <Setter Property="BorderThickness" Value="0"/> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="Padding" Value="0" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="RichTextBox"> <Grid Background="Transparent"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Margin="{StaticResource PhoneHorizontalMargin}"> <ContentControl x:Name="ContentElement" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Padding="{TemplateBinding Padding}"/> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
Notice we are using an implicit style (yay for Silverlight 4 on the phone!! )
Another known issue with the current beta build is that images are not showing up in the rich textbox (they show up in the designer in Visual Studio/Blend )but not at run-time. This is also fixed in later builds. Still, the template above should be enough to get you rolling with RichTextBox.
Happy Windows Phone coding!!