Your SlideShare is downloading. ×
Do not do more copy and paste between windows store and windows phone apps
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Do not do more copy and paste between windows store and windows phone apps


Published on

See more information in

See more information in

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide
  • MVVM Light Source Code:Open Win8 and WP8 Solution ;Show CodeHow to do “Add as Link” – use the RelayCommand – file is inside the .Net3,5Show directives - RelayCommandParcial class in diferent files. Show the WeakFunc.Win8
  • Creating a empty PCL projectShow the dialog for choose the targetsEdit the targetsShow the subset
  • Be Pragmatic: Develop UX specific to the target platformDon’t attempt to share UX resources (styles, controls, pages etc)Reuse and share code between platforms
  • Transcript

    • 1. 35th Meeting in Lisbon - 26/01/2013 Don´t do more "copy and paste" between Windows Store and Windows Phone Apps Sara Silva
    • 2. Sara SilvaWindows 8 & Windows Phone Developer  MCPD: Windows Developer 3.5  MCTS: WPF 3.5/4.0 and Windows Forms 3.5  Math Degree: Specialization in Computing - DMUCCommunities :
    • 3. Agenda• Introdution• Sharing code files• Portable Class Library• Portable Class Library + MVVM• Libraries• Conclusion
    • 4. Introdution 2 Platforms Pílula WP Pílula Win8 6 projects Galinho WP Galinho Win8 3 applications 24 WP 24 Win8Nota: Same version for WP7.5 and WP8
    • 5. Introdution• Repeated code between projects => 2 times the same task.• Bug in WP => bug in Win8 and vice versa => 2 times the same correction.• Less features.• Less time for others taks.• Cost are double: “If the cost for the company is Y €/hour => 2*Y€/hour” “If the cost is sleep time => Less time sleeping ”• Demotivation for developers.
    • 6. Share code files• Use “Add as Link” to include same files in multiple projects.• Use directives for platform specifications.• Use partial class and partial methods.• Change once, change everywhere. “Reusing code by including code files in multiple projects.”
    • 7. Share code filesUsing directives: It can “generate” • NETFX_CORE Windows 8 code unreadable • WINDOWS_PHONE Windows Phone #if !NETFX_CORE public object Convert(object value, Type targetType, object parameter, CultureInfo culture) #else public object Convert(object value, Type targetType, object parameter, string culture) #endif
    • 8. Share code filesPartial Classes and partial methods• Shared functionality in one code file.• Platform specific code in additional code file.• Classes are marked as partial and compiled into a single class.• Separates platform specific features.• Can use partial methods as a mechanism to separate out platform specific logic. DataSource.cs | DataSource.WP8.cs | DataSource.Win8.cs
    • 9. Share code filesExample, MVVM Light toolkit :
    • 10. “Add as Link”
    • 11. Portable Class LibraryMore help for developing cross-platform applications using. NetFramework, since it allows you to create "portable assemblies"that can be referenced in projects for multiple platforms withoutthe need to make changes.Will contain the lowest common denominator types: • .NET Framework • Silverlight • .NET for Windows Store apps, • Windows Phone • Xbox 360
    • 12. Portable Class LibraryFeatures supported on various platforms *: * .Net Framework greater or equal to 4.0.3
    • 13. Portable Class LibraryThe documentation on MSDN announces support:
    • 14. Portable Class LibraryVisual Studio 2010 (Extention +SP1) and 2012 provides a Portable Class Library project template.“targets” definitions: When create a project Editing the target in a project
    • 15. Portable Class LibraryVisual Studio 2010 (Extenstion +SP1) and 2012 provides a Portable Class Library project template.Result: “ One Source One Project One Binary Multiple Platforms!”
    • 16. Portable Class Library Project
    • 17. Portable Class Library• Not contains types related to UI because the UI behavior differs between the different platforms;• Windows 8 is required for create Windows Store Apps, but is not required for create Portable Class Libraries that supports Windows Store Apps.• Silverlight-based application must ensure that the minimum runtime version required for the application is set to version 4.0.60129.0 or later <param name="minRuntimeVersion" value="4.0.60129.0" />
    • 18. Portable Class Library + MVVM
    • 19. Portable Class Library + MVVMAvailable classes to help MVVM implementation:System.Collections.ObjectModel• ObservableCollection<T> class• ReadOnlyObservableCollection<T> classSystem.Collections.Specialized• INotifyCollectionChanged class• NotifyCollectionChangedAction class• NotifyCollectionChangedEventArgs class• NotifyCollectionChangedEventHandler classSystem.ComponentModel• DataErrorsChangedEventArgs class• INotifyDataErrorInfo class• INotifyPropertyChanged class• System.Windows.Input.ICommand class• All classes in the System.ComponentModel.DataAnnotations namespace
    • 20. Consuming Odata Service
    • 21. Architecture *only external portable libraries
    • 22. Libraries• Microsoft.Bcl.Async Allow to use async/await without .Net Framework 4.5• Portable Toolkit for MVVM Fork from toolkit MVVM Light: Portable.MvvmLightLibs• MvvmCross Library for MVVM in Windows Phone, Windows Store, iOS, and Android• Portable Class Libraries Contrib Portable adapters and APIs• Json.NET JSON framework
    • 23. Conclusion • Separate UI from app logic using the Model-View-ViewModel pattern. • Share portable .NET code in Portable Class Library • “Abstactration pattern is the key” • Dependency injection allow to encapsulate platform specifications. • Use common Windows Runtime API (Add as Link) • If necessary, extend shared classes to add specific functionality of the platform. • When we want to share code, designing the architecture should bear this in mind!
    • 24. Q&A
    • 25. References• Cross-Platform Development with the .NET Framework• Using Portable Class Library with Model-View-View Model• Create Cross-platform Apps using Portable Class Libraries• Building Apps for Windows Phone 8 Jump Start (MVA)• Visual Studio Toolbox:Portable Class Libraries• Create a Continuous Client Using Portable Class Libraries• How to Leverage your Code across WP8 and Windows 8• Portable Library Articles series by Jeremy Likness• How to Make Portable Class Libraries Work for You• Portable Class Library Enlightenment / Adaptation• Portable Class Libraries – Net Framework 4.0• Portable Class Libraries – Net Framework 4.5
    • 26. Others Samples• PortableNotepad - This sample shows how to access non-portable functionality from portable code by creating a portable abstraction with platform-specific implementations. Goals: Abstraction for Load / Save data in files Projects: Windows Phone, Windows Store App, WPF App• ContosoHelpdesk – This demo show advanced concepts. Goals: Navigation, inversion of control, and synchronizing data across multiple clients with Windows Azure Service Bus. Projects: Windows Phone, Windows Store App Note: Use Autofac portable library (IoC Container)• TwitterSearch – This sample shows how to create a twitter search client. Goals: Twitter Search API, Azure Mobile Services, Projects: Windows Phone, Windows Store App, Console App Note: Use MVVMCross portable library• Disentanglement - This is a solver for Thinkfuns Gordians Knot puzzle which runs on Windows and Windows Phone. It uses a Portable Class Library to share the solver code between the different platforms Goals: Share the solver code. Projects: Windows Phone App, Desktop App, Xbox App• PixPresenter - is a photo sharing app that enables you to connect to another device using Proximity (NFC) and a tap gesture, and then send pictures back and forth between the connected devices. It demonstrates code sharing techniques that you can use when developing an app for bot Goals: Windows Runtime API common code Projects: Windows Phone, Windows Store App (C# and C++)
    • 27. Sponsors “GOLD” Twitter: @PTMicrosoft
    • 28. Sponsors “Silver”
    • 29. Sponsors “Bronze”
    • 30. Upcoming meetings• 23/02/2013 – February (Lisbon) 16/03/2013 – March (Lisbon) Reserve these days! :)
    • 31. Thanks!Sara Silvageral@saramgsilva.comhttp://www.saramgsilva.com