introduction to universal apps-jaliya udagedara

51
Introduction to Universal Apps Jaliya Udagedara MVP (Visual C#)

Upload: jaliya-udagedara

Post on 17-Jul-2015

665 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Introduction to Universal Apps-Jaliya Udagedara

Introduction to Universal Apps

Jaliya UdagedaraMVP (Visual C#)

Page 2: Introduction to Universal Apps-Jaliya Udagedara
Page 3: Introduction to Universal Apps-Jaliya Udagedara
Page 4: Introduction to Universal Apps-Jaliya Udagedara
Page 5: Introduction to Universal Apps-Jaliya Udagedara
Page 6: Introduction to Universal Apps-Jaliya Udagedara
Page 7: Introduction to Universal Apps-Jaliya Udagedara

Windows Store App

Windows Phone Store App

Page 8: Introduction to Universal Apps-Jaliya Udagedara

Windows Runtime Apps

Page 9: Introduction to Universal Apps-Jaliya Udagedara
Page 10: Introduction to Universal Apps-Jaliya Udagedara

Windows Runtime contains more than 90% of Windows

Phone Runtime

Page 11: Introduction to Universal Apps-Jaliya Udagedara
Page 12: Introduction to Universal Apps-Jaliya Udagedara
Page 13: Introduction to Universal Apps-Jaliya Udagedara
Page 14: Introduction to Universal Apps-Jaliya Udagedara
Page 15: Introduction to Universal Apps-Jaliya Udagedara

protected override async void OnLaunched(LaunchActivatedEventArgs e){

ApplicationExecutionState state = e.PreviousExecutionState;

ActivationKind kind = e.Kind;

///...}

Page 16: Introduction to Universal Apps-Jaliya Udagedara

• App is suspended

• All code stopped

• No timers tick

• No events fire

• Process still alive and in memory

• Code has a chance to respond (next slide)

Page 17: Introduction to Universal Apps-Jaliya Udagedara

private async void OnSuspending(object sender, SuspendingEventArgs e){

var deferral = e.SuspendingOperation.GetDeferral();

await SuspensionManager.SaveAsync(); deferral.Complete();

}

Page 18: Introduction to Universal Apps-Jaliya Udagedara

• Same app is resumed

• Same process, same memory so values of variables are intact

• All code runs

• Code has a chance to respond.

Launch Switcher

Page 19: Introduction to Universal Apps-Jaliya Udagedara

public App() {

this.InitializeComponent();this.Suspending += this.OnSuspending;this.Resuming += App_Resuming;

}

void App_Resuming(object sender, object e){

// TODO: whatever you need to do to resume your app}

Page 20: Introduction to Universal Apps-Jaliya Udagedara

http://bit.ly/w8Resuming

Page 21: Introduction to Universal Apps-Jaliya Udagedara
Page 22: Introduction to Universal Apps-Jaliya Udagedara
Page 23: Introduction to Universal Apps-Jaliya Udagedara
Page 24: Introduction to Universal Apps-Jaliya Udagedara

Window

Frame

PageWindow

Page 25: Introduction to Universal Apps-Jaliya Udagedara

protected override void OnLaunched(LaunchActivatedEventArgs e){

Frame rootFrame = Window.Current.Content as Frame;

// Do not repeat app initialization when the Window already has// content, just ensure that the window is activeif (rootFrame == null){

// Create a Frame to act as the navigation context and navigate// to the first pagerootFrame = new Frame();

...

// Place the frame in the current WindowWindow.Current.Content = rootFrame;

}

if (rootFrame.Content == null){

// Navigate to the first pagerootFrame.Navigate(typeof(MainPage), e.Arguments);

}// Ensure the current window is activeWindow.Current.Activate();

}

Page 26: Introduction to Universal Apps-Jaliya Udagedara

private void itemListView_ItemClick(object sender, ItemClickEventArgs e)

{

// Navigate to the appropriate destination page, configuring the new page

// by passing required information as a navigation parameter

var itemId = ((MyListViewItem)e.ClickedItem).UniqueId;

Frame.Navigate(typeof(MyDetailPage), itemId);

}

Page 27: Introduction to Universal Apps-Jaliya Udagedara

private void btnGoBack_Click(object sender, RoutedEventArgs e)

{if (this.Frame.CanGoBack)

this.Frame.GoBack();}

Page 28: Introduction to Universal Apps-Jaliya Udagedara
Page 29: Introduction to Universal Apps-Jaliya Udagedara
Page 30: Introduction to Universal Apps-Jaliya Udagedara

public sealed partial class SecondPage : Page{

...

protected override void OnNavigatedTo(NavigationEventArgs e){

Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;}

protected override void OnNavigatedFrom(NavigationEventArgs e){

Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed;}

async void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e){

e.Handled = true; // We've handled this button press

if (SecondaryUI.Visibility == Visibility.Visible ) // If the secondary UI is visible, hide it{

FadeOutSecondaryStoryboard.Begin();}else{

if (Frame.CanGoBack)Frame.GoBack();

}}

Page 31: Introduction to Universal Apps-Jaliya Udagedara
Page 32: Introduction to Universal Apps-Jaliya Udagedara
Page 33: Introduction to Universal Apps-Jaliya Udagedara
Page 34: Introduction to Universal Apps-Jaliya Udagedara
Page 35: Introduction to Universal Apps-Jaliya Udagedara
Page 36: Introduction to Universal Apps-Jaliya Udagedara

Add Windows Phone 8.1 or Windows 8.1

Page 37: Introduction to Universal Apps-Jaliya Udagedara

Context Switcher in the Editor

Page 38: Introduction to Universal Apps-Jaliya Udagedara

Context Switcher in the XAML Editor

Page 39: Introduction to Universal Apps-Jaliya Udagedara

Better IntelliSense

Page 40: Introduction to Universal Apps-Jaliya Udagedara

Devices Window

Page 41: Introduction to Universal Apps-Jaliya Udagedara

Switching Startup Projects

Page 42: Introduction to Universal Apps-Jaliya Udagedara
Page 43: Introduction to Universal Apps-Jaliya Udagedara
Page 44: Introduction to Universal Apps-Jaliya Udagedara
Page 45: Introduction to Universal Apps-Jaliya Udagedara

• Code Sharing Strategies

• Linked Files

• PCL

• Shared Projects

Page 46: Introduction to Universal Apps-Jaliya Udagedara
Page 47: Introduction to Universal Apps-Jaliya Udagedara
Page 48: Introduction to Universal Apps-Jaliya Udagedara
Page 49: Introduction to Universal Apps-Jaliya Udagedara

• XAML Sharing Strategies

• Solving Styles

Page 50: Introduction to Universal Apps-Jaliya Udagedara
Page 51: Introduction to Universal Apps-Jaliya Udagedara

Thank You!http://www.jaliyaudagedara.blogspot.com/