如何使用Visual Studio Professional 2012爲Windows Phone 8和Windows 8(平板電腦)開發應用程序?我希望能夠重用大部分代碼。Windows 8和Windows Phone 8
11
A
回答
30
如何獲得高代碼重用的一些想法:
- 目前XAML可能是你最好的語言選擇...很多的Win8和WP8之間的重疊。這是一個XAML controls comparison between Windows Phone 8 and Windows 8。
- 槓桿MVVM pattern。這爲您的UI和應用程序邏輯提供了一個很好的解耦。
- 使用portable class libraries(可在Win8,WP8和其他平臺上使用的DLL)。更多信息here。
- 或者使用"Add as link"來引用Win8和WP8中的同一個源文件。這樣,您將源代碼保存在一個地方,但Win8和WP8應用程序都使用它。
- 使用conditional compilation。例如,這將使您能夠僅爲Windows 8編譯某些代碼塊。謹慎使用是很好的,但如果你經常發現自己使用這種技術,你的代碼會變得很難閱讀和維護。
- 這個視頻來自BUILD 2012的How to Leverage your Code across WP8 and Windows 8是有幫助的。
- http://aka.ms/ShareCode和Getting started developing apps for Windows Phone 8 and Windows 8有很多有用的鏈接。
- 側注意:如果您正在爲兩者開發,您擁有Visual Studio Professional是很好的。您可以使用免費版本(適用於Windows 8的Visual Studio Express和適用於Windows Phone的Visual Studio Express,均可下載here)進行開發,但對於Professional,您可以打開一個Visual Studio實例並引用這兩種類型的項目在相同的解決方案。
+0
真棒回答詹妮弗! –
+0
大信息珍妮弗! –
2
1
是的,但您需要使用不同的項目模板。您還需要Windows 8 SDK和Windows Phone 8 SDK。
如果您使用XAML
,您可以輕鬆地在項目中遷移(不含電話功能和合同)。
0
對於Windows Phone 8,您必須安裝windows phone sdk,它可以在微軟官方網站上使用,對於不需要安裝SDK的平板電腦,它已經在安裝的項目中可用。
相關問題
- 1. Windows 8中的Windows Phone 8
- 2. Windows Phone 8和Windows 8平板電腦
- 3. Windows Phone 8和ATL
- 4. Windows Phone 8和D3DCompiler
- 5. Windows Phone 8
- 6. Windows Phone的8
- 7. Windows Phone 8 ScrollViewer
- 8. MediaPlaybackControls Windows Phone 8
- 9. Windows Phone 8 TextBlock
- 10. Windows Phone 8 System.Reflection.TargetInvocationException
- 11. IsolatedStorage Windows phone 8
- 12. Popup Windows phone 8
- 13. Windows phone 8 XMLParseException
- 14. Windows Phone 8 LongListSelector
- 15. Windows Phone 7和Windows Phone 8/Windows 8之間的代碼共享(Windows Store)
- 16. Windows Phone 8 - MVVM ViewModels和App.xaml.cs
- 17. Windows phone 7和8 AdMob
- 18. Windows Phone 8 HTML5 - window.innerWidth和window.innerHeight
- 19. Windows Phone 8和Azure AD/ACS
- 20. TimePicker和dispatcherTimer windows phone 8
- 21. WCF與HTTPS和Windows Phone 8
- 22. 從windows phone到windows 8
- 23. LockScreen for windows phone 8
- 24. 在的Windows Phone 8
- 25. MainviewModel的Windows Phone 8
- 26. AVRCP for Windows phone 8?
- 27. 爲Windows Phone 8的
- 28. OpenTK C#Windows Phone(8)
- 29. Windows Phone 8. Deep Toast
- 30. Windows phone 8漢化
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681693%28v=vs.105%29.aspx可能會有所幫助。 –
@KenWhite你應該將其作爲答案張貼 - 人們可能會在評論中忽略它。 –