Windows Phone 7 apps development with SilverlightPresentation Transcript
Silverlight programming on Microsoft Phone Radu Poenaru Microsoft Student Partner
What we are trying to achieve How to create a simple Silverlight app Use Blend 4 for Phone for design http://70gigapixel.cloudapp.net/
What is Silverlight? “Silverlight is a powerful development platform for creating engaging, interactive user experiences for Web, desktop, and mobile applications when online or offline.” Microsoft Official Silverlight website http://www.silverlight.net/
Silverlight Very powerful framework Same known XAML and C# Windows, Mac, Linux and now Phone Learning curve is smooth
Silverlight capacities Data Inputs
Language Integrated Query (LINQ)
LINQ to XML
Base Class Library (BCL) XAML
Windows Communication Foundation Media
Digital media capture & playback
VC1, WMA, MP3
What about Silverlight for Phone It is a superset of Silverlight 3 having several elements from Silverlight 4 and many extras: Performance tuning Input integration Hardware media and sensor integration OS application model integration Relaxed sandbox constraints
back key details Lets the user to return to previously-viewed screens Can go back across applications Not used for application-specific behaviour
a world of constant interruptions phone calls low battery lock screen reminders App switch txt msgs :-)
basic application lifetime
obscured: popup ui from shell Not in the Mix build
Games could auto-pause Game could auto-resume What if they answer the phone?
paused: jump to another app Not in the Mix build
Load state to continue where you left off User never knows what happened :-) Assume your process is killed Save state for later use
Evaluating app performance
Render Thread FPS: The number of frames per second that the independent simple animations and rendering thread is using.
User Interface Thread FPS: The number of fps that the primary user interface thread is experiencing
Texture Memory Usage: A specialized memory counter indicating the video memory used for storing application textures.
Surface Counter: A count of the number of surfaces that are passed to the graphics chip.
Intermediate Texture Count: The number of intermediate textures created for compositing.
Screen Fill Rate: A metric representing the number of complete phone screens being painted each and every frame.
Basics XAML – eXtensible Application Markup Language XML with custom tags Maps to code Can contain as children resources styles controls supports binding Anything that is done in XAML can be done in code
Shapes Vector- based Easy to scale, keeping the smoothness Can be easily imported from Photoshop or Illustrator Example(ellipse code):
Brushes Determines how objects are painted and outlined Solid – filled with just one color Gradient – linear or radial with multiple stop points Image – shows an image in the brush Media – paints with a playing movie Let‘s see a Demo!
Controls Encapsulate functionality Requires a x:Name if you plan to call it from the code Same properties in XAML as in Code
Events Can be created in XAML and Code XAML editor helps you create a handler
Layout containers Flexible Layout system Canvas – fixed position StackPanel – „Stacks“ dynamically Grid – rows and columns, very flexible Can be nested – but beware of performance issues
Demo Layout demo Attached properties
Transforms Alters any element Controls Text Media Transforms Rotate, Scale, Skew ,Translate, Matrix Projections Plane, Matrix, Apply 3D to a 2D element
Animations Animates a property value over the time Basic elements in a page Contains one or more Storiboards Contains one or more Animations Contains one or more Keyframes Expression Blend is the best tool to do this Let‘s see some demo!
Styling Applies a set of values to a specific target type Created in page Resources, application Resources or a ResourceDictionary Requires x:Key TargetType On the element – StaticResource pointing to the x:Key
Binding Connects data to UI Two types Property binding List binding Value converters – ex take color Red and convert it to hex representation Based on change notification Cascades through the hierarchy of controls
Code reuse Reuse UI User controls Custom controls Reuse code Across projects Across platforms – Web, Desktop through OOB, Phone
References Search for Silverlight 3 source: Forums, books, podcasts http://silverlight.net http://www.stackoverflow.com Get Started with Silverlight for Windows Phone http://www.silverlight.net/getstarted/devices/windows-phone/ Silverlight for Windows Phone forum http://forums.silverlight.net/forums/63.aspx Mix 2010 event http://live.visitmix.com/Sessions
Do you have questions ? Comments and sugestions are welcome! email@example.com www.radupoenaru.com Thank you!