+ All Categories
Home > Documents > Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 ›...

Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 ›...

Date post: 01-Jul-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
20
Transcript
Page 1: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner
Page 2: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Cross Platform DevelopmentWindows 8 Windows Phone 8 Daniel Meixner

#dmxDevSession

Page 3: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Agenda

• Programmiermodelle

• Gemeinsamkeiten & Unterschiede

• Cross Plattform Strategien

Page 4: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Programmiermodell Windows 8

Page 5: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Programmiermodell Windows Phone 8

.NET API for

Windows

Phone

Windows

Phone

Runtime

Win32 &

COM

Managed Native

WP7.1 XAML & C#/VB

WP8.0 XAML & C#/VB

WP8.0 Games DirectX/Direct 3D & C++

WP7.1 XNA & C#/VB

WP8.0 XAML & C#/VB with Direct3D Graphics

+ C++

+ C++

Page 6: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Shared core

Full WinRT11,000 members

Windows Phone Runtime2,800 shared members

600 new members

Page 7: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Gemeinsamkeiten & Unterschiede

3/15/2013

Screen Size

Windows Phone

• 800x480, 1280x720, 1280x768Portrait, Landscape

Windows

• 1024x768 Portrait, Landscape, Snapped

Controls

Windows Phone

• Panorama, Pivot, ListPickerLongListSelector

Windows

• GridView, ListView, Semantic Zoom, FlipView

Lifecycle

Windows Phone

• Launched from start/apps list.Tombstones apps

Windows

• Resumes existing appsNo tombstoning

Page 8: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Cross Plattform Strategien (XAML/C#)

Page 9: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Reuse: Portable Class Library

Reusing pre-built components or libraries

3/15/2013Microsoft

confidential

9

• Portable Class Library

• Managed Code

• Reusable library

• One codebase with no conditional compilation

Page 10: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Shared Code: File-Level (Add as Link)

• App logic common to both apps, but not portable

• Code containing Windows Runtime API calls

• User controls with no platform dependencies

Page 11: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Shared Code: Classpart-Level (Partial Classes)

public partial class MyClass{

public void CommonMethodA(){

// code that is common}

public int CommonMethodB(){

int result = 0;// code that is commonreturn result;

}

}

public partial class MyClass{

public void PlatformSpecificMethod(){

// specific code for platform Á}

}}

public partial class MyClass{

public void PlatformSpecificMethod(){

// specific code for platform B}

}

Page 12: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Shared Code: Classpart-Level (Partial Classes)

• Very useful if amount of common code is large relative to the amount of platform-specific code

• I cannot specify what each platform-specific partial class should implement

Page 13: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Shared Code: Line Level (Conditional Compilation)

• can’t be shared in a Portable Class Library

• simple way to share code

• Complexity!

public class MyClass{

public void CommonMethodA(){

// code that is common to Windows Phone 8 and Windows 8}

public int CommonMethodB(){

int result = 0;// code that is common to Windows Phone 8 and Windows 8return result;

}

public void PlatformSpecificMethod(){

#if NETFX_CORE// code for Windows 8#else// code for Windows Phone 8#endif

}}

Page 14: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Shared UI: XAML Controls

• Limited to basic user controls

• Always build your user experience to suit the target platform!

<UserControl x:Class="MyApp.Shared.Controls.MyControl"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"

d:DesignHeight="480" d:DesignWidth="480">

<Grid x:Name="LayoutRoot" Background="Black">

<StackPanel >

<TextBox x:Name="InputText"/>

<Button x:Name="SayHelloButton" Content="Say Hello!"/>

</StackPanel>

</Grid>

</UserControl>

Page 15: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

public class MyWin8Class : MyBaseClass{

public override void PlatformSpecificMethod(){// Implement this method specific to Win 8}

} }

Patterns: Abstract Base Class

public abstract class MyBaseClass{

public void CommonMethodA(){

// code that is common}

public int CommonMethodB(){

int result = 0;

// code that is commonreturn result;

}

public abstract void PlatformSpecificMethod();}

Add as Link

Portable Class Library

public class MyWP8Class : MyBaseClass{

public override void PlatformSpecificMethod(){// Implement this method specific to WP8}

}

Page 16: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

public class MyClass{

private IPlatformSpecificCode _platformImpl;

public MyClass(IPlatformSpecificCode platformImpl){

_platformImpl = platformImpl;}

public void CommonMethodA(){ ... }

public int CommonMethodB(){ ... }

public void PlatformSpecificMethod(){

_platformImpl.PlatformSpecificMethodImpl();}

}

public interface IPlatformSpecificCode{

void PlatformSpecificMethodImpl();}

// Windows 8 app projectpublic class MyWin8Implementation : IPlatformSpecificCode

{public void PlatformSpecificMethod(){

// Implemented for Windows 8}

}

Patterns: Interfaces

// Windows Phone app projectpublic class MyWinPhone 8Implementation : IPlatformSpecificCode

{public void PlatformSpecificMethod(){

// Implemented for Windows Phone 8}

}

Page 17: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Demo

Page 18: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Summary

• Shared design language

• Shared core

• Several approaches to share parts

3/15/2013Microsoft

confidential

1

8

Page 19: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

Daniel MeixnerTechnical Evangelist

#dmxDevSession

Ping me!

Page 20: Cross Platform Development Windows 8download.microsoft.com › download › 8 › E › 8 › 8E874164-7B1A-4D52...Cross Platform Development Windows 8 Windows Phone 8 Daniel Meixner

© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered

trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this

presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of

Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES

NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Vielen Dank.


Recommended