SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Microsoft Leader club
   Session One – Dev Windows Phone 8
               08/03/2013
APP CAMPUS
Get €50,000 for your Windows Phone app idea!
The winner will also get a free trip to Finland to
participate in a 4-week developer camp. Compete
for the Worldwide Imagine Cup AppCampus
Award! Top finalists incorporating a Windows
Phone app into their project are eligible to win.
Through this mobile application accelerator
program, Microsoft and Nokia provide grants to
fund innovative, first-to-market ideas with a fresh
approach on design elegance, superior quality
and performance
WINDOWS PHONE DEV CENTER
The Windows Phone Emulator
•The Windows Phone
emulator runs as a Hyper-V
virtual machine on your
Windows PC
• •It contains the same
  software as a “real” phone,
  but built for the Windows
  PC platform
Page Navigation

Frame and Page
•Frame
•Top-level container control
•PhoneApplicationFrame class
•Contains the page control and system
elements such as system tray and
application bar
•Page
•Fills entire content region of the frame
•PhoneApplicationPage-derived class
•Contains a title
•Optionally surfaces its own application
bar
Using a Grid to Aid Landscape Layout

•   <phone:PivotItem Header="recipe">
•   <Grid>
•   <Grid.ColumnDefinitions>
•   <ColumnDefinition Width="*"/>
•   <ColumnDefinition Width="Auto"/>
•   </Grid.ColumnDefinitions>
•   <Grid.RowDefinitions>
•   <RowDefinition Height="Auto"/>
•   <RowDefinition Height="240"/>
•   <RowDefinition Height="*"/>
•   <RowDefinition Height="Auto"/>
•   </Grid.RowDefinitions>
•   ...
•   </Grid>
Handling Screen Orientation
Changes
Selecting Orientations

SupportedOrientations="Portrait«

SupportedOrientations="PortraitOrLandscape«

• •A XAML property for the phone application page lets
  you select the orientation options available
• •Your application can bind to an event which is fired
  when the orientation changes
Moving Elements

• private void PhoneApplicationPage_OrientationChanged(object sender,
  OrientationChangedEventArgs e) { if (this.Orientation ==
  PageOrientation.LandscapeLeft || this.Orientation ==
  PageOrientation.LandscapeRight) {
  DirectionsScrollViewer.SetValue(Grid.RowProperty, 1);
  DirectionsScrollViewer.SetValue(Grid.ColumnProperty, 1); } else {
  DirectionsScrollViewer.SetValue(Grid.RowProperty, 2);
  DirectionsScrollViewer.SetValue(Grid.ColumnProperty, 0); } }
Page Navigation
•XAML apps on Windows Phone use
a page-based navigation model
•Similar to web page model
•Each page identified by a URI
•Each page is essentially stateless

private void HyperlinkButton_Click_1( object sender,
RoutedEventArgs e)
{
NavigationService.Navigate( new
Uri("/SecondPage.xaml", UriKind.Relative));
}
Navigating Back
•Application can provide controls to navigate
back to preceding page

•The hardware Back key will also navigate
back to preceding page
•No code required – built-in behaviour

private void Button_Click_1( object sender,
RoutedEventArgs e)
{
NavigationService.GoBack();
}
Passing Data Between Pages
• •Can pass string data between pages using query strings
private void passParam_Click(object sender, RoutedEventArgs e) {
NavigationService.Navigate(new Uri("/SecondPage.xaml?msg=" + textBox1.Text,
UriKind.Relative)); }
• •On destination page
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string querystringvalue = "";
if (NavigationContext.QueryString.TryGetValue("msg", out querystringvalue))
textBlock1.Text = querystringvalue; }
Isolated Storage Classes

• •The IsolatedStorage classes are all in the System.IO.IsolatedStorage
  namespace
• •IsolatedStorageFile
• •Represents an isolated storage area containing files and directories
• •IsolatedFileStream
• •Exposes a file stream access to a file stored within isolated storage
• •IsolatedStorageSettings
• •Dictionary<(Of <(TKey, TValue>)>) that stores key-value pairs in isolated
  storage
Local Folder
• •All read-write I/O operations restricted to local folder
• •Create a files and folder structure hierarchy
• •Use Isolated Settings storage to store application settings
Saving Data
private void saveGameToIsolatedStorage(string message)
{
using (IsolatedStorageFile isf =
IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream rawStream =
isf.CreateFile("MyFile.store"))
{
StreamWriter writer = new StreamWriter(rawStream);
writer.WriteLine(message); // save the message
writer.Close();
}
}
}
Loading Data
private string loadString()
{
string result = null;
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
if (isf.FileExists("Myfile.store")
{
using (IsolatedStorageFileStream rawStream = isf.OpenFile(filename,
System.IO.FileMode.Open)) {
StreamReader reader = new StreamReader(rawStream);
result = reader.ReadLine();
reader.Close();
}}}
return result;
}
Capture Camera
Code XAML
<Button x:Name="CaptureCameraButton" Content="Capture Camera" Width="300" Height="100"
Margin="0,81,156,426" Click="CaptureCameraButton_Click" />
<Image Height="150" HorizontalAlignment="Left" Margin="12,348,0,0" Name="image1" Stretch="Fill"
VerticalAlignment="Top" Width="200" />
Code c#
private void CaptureCameraButton_Click(object sender, RoutedEventArgs e)
{
CameraCaptureTask cct = new CameraCaptureTask();
cct.Completed += new EventHandler<PhotoResult>(cct_Completed);
cct.Show();
}

void cct_Completed(object sender, PhotoResult e)
{
BitmapImage bmp = new BitmapImage();
bmp.SetSource(e.ChosenPhoto);
image1.Source = bmp;
}
Get PHOTO
Code XAML
• <Button x:Name="GetPhotoButton" Content="Get Photo" Width="300" Height="100" Margin="0,242,156,265"
  Click="GetPhotoButton_Click" />
• <Image Height="150" HorizontalAlignment="Left" Margin="12,348,0,0" Name="image2" Stretch="Fill"
  VerticalAlignment="Top" Width="200" />

Code c#
private void GetPhotoButton_Click(object sender, RoutedEventArgs e)
{
PhotoChooserTask pct = new PhotoChooserTask();
pct.Completed += new EventHandler<PhotoResult>(pct_Completed);
pct.Show();
}

void pct_Completed(object sender, PhotoResult e)
{
BitmapImage bmp = new BitmapImage();
bmp.SetSource(e.ChosenPhoto);
image2.Source = bmp;
}
Anwar YAHYAOUI
• President du club Microsoft Leader
• Email: anwar.yahyawi@live.fr
• Mobile: (+216) 24 23 41 73

Weitere ähnliche Inhalte

Ähnlich wie Session 1

Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WAREFermin Galan
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on MobileAdam Lu
 
Extending eZ Platform v2 with Symfony and React
Extending eZ Platform v2 with Symfony and ReactExtending eZ Platform v2 with Symfony and React
Extending eZ Platform v2 with Symfony and ReacteZ Systems
 
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rulesSrijan Technologies
 
Presentation - Windows App Development - II - Mr. Chandan Gupta
Presentation - Windows App Development - II - Mr. Chandan GuptaPresentation - Windows App Development - II - Mr. Chandan Gupta
Presentation - Windows App Development - II - Mr. Chandan GuptaMobileNepal
 
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EEJavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EERodrigo Cândido da Silva
 
Windows Phone 8 - 3 Building WP8 Applications
Windows Phone 8 - 3 Building WP8 ApplicationsWindows Phone 8 - 3 Building WP8 Applications
Windows Phone 8 - 3 Building WP8 ApplicationsOliver Scheer
 
Eclipse 40 - Eclipse Summit Europe 2010
Eclipse 40 - Eclipse Summit Europe 2010Eclipse 40 - Eclipse Summit Europe 2010
Eclipse 40 - Eclipse Summit Europe 2010Lars Vogel
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedToru Wonyoung Choi
 
Rp 6 session 2 naresh bhatia
Rp 6  session 2 naresh bhatiaRp 6  session 2 naresh bhatia
Rp 6 session 2 naresh bhatiasapientindia
 
SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4Jon Galloway
 
Solid fire cloudstack storage overview - CloudStack European User Group
Solid fire cloudstack storage overview - CloudStack European User GroupSolid fire cloudstack storage overview - CloudStack European User Group
Solid fire cloudstack storage overview - CloudStack European User GroupShapeBlue
 
CloudStack Meetup London - Primary Storage Presentation by SolidFire
CloudStack Meetup London - Primary Storage Presentation by SolidFire CloudStack Meetup London - Primary Storage Presentation by SolidFire
CloudStack Meetup London - Primary Storage Presentation by SolidFire NetApp
 
Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 seriesopenbala
 
Modernize Your Real-World Application with Eclipse 4 and JavaFX
Modernize Your Real-World Application with Eclipse 4 and JavaFXModernize Your Real-World Application with Eclipse 4 and JavaFX
Modernize Your Real-World Application with Eclipse 4 and JavaFXCole Markham
 
Extending eZ Platform 2.x with Symfony and React
Extending eZ Platform 2.x with Symfony and ReactExtending eZ Platform 2.x with Symfony and React
Extending eZ Platform 2.x with Symfony and ReactPiotr Nalepa
 
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architectureAndroid Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architectureNicheTech Com. Solutions Pvt. Ltd.
 
Android Workshop 2013
Android Workshop 2013Android Workshop 2013
Android Workshop 2013Junda Ong
 

Ähnlich wie Session 1 (20)

JSF2
JSF2JSF2
JSF2
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WARE
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on Mobile
 
Extending eZ Platform v2 with Symfony and React
Extending eZ Platform v2 with Symfony and ReactExtending eZ Platform v2 with Symfony and React
Extending eZ Platform v2 with Symfony and React
 
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
 
Presentation - Windows App Development - II - Mr. Chandan Gupta
Presentation - Windows App Development - II - Mr. Chandan GuptaPresentation - Windows App Development - II - Mr. Chandan Gupta
Presentation - Windows App Development - II - Mr. Chandan Gupta
 
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EEJavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
 
Windows Phone 8 - 3 Building WP8 Applications
Windows Phone 8 - 3 Building WP8 ApplicationsWindows Phone 8 - 3 Building WP8 Applications
Windows Phone 8 - 3 Building WP8 Applications
 
Eclipse 40 - Eclipse Summit Europe 2010
Eclipse 40 - Eclipse Summit Europe 2010Eclipse 40 - Eclipse Summit Europe 2010
Eclipse 40 - Eclipse Summit Europe 2010
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO Extended
 
Rp 6 session 2 naresh bhatia
Rp 6  session 2 naresh bhatiaRp 6  session 2 naresh bhatia
Rp 6 session 2 naresh bhatia
 
SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4
 
Solid fire cloudstack storage overview - CloudStack European User Group
Solid fire cloudstack storage overview - CloudStack European User GroupSolid fire cloudstack storage overview - CloudStack European User Group
Solid fire cloudstack storage overview - CloudStack European User Group
 
CloudStack Meetup London - Primary Storage Presentation by SolidFire
CloudStack Meetup London - Primary Storage Presentation by SolidFire CloudStack Meetup London - Primary Storage Presentation by SolidFire
CloudStack Meetup London - Primary Storage Presentation by SolidFire
 
Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 series
 
Modernize Your Real-World Application with Eclipse 4 and JavaFX
Modernize Your Real-World Application with Eclipse 4 and JavaFXModernize Your Real-World Application with Eclipse 4 and JavaFX
Modernize Your Real-World Application with Eclipse 4 and JavaFX
 
Extending eZ Platform 2.x with Symfony and React
Extending eZ Platform 2.x with Symfony and ReactExtending eZ Platform 2.x with Symfony and React
Extending eZ Platform 2.x with Symfony and React
 
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architectureAndroid Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
 
Android Workshop 2013
Android Workshop 2013Android Workshop 2013
Android Workshop 2013
 

Session 1

  • 1. Microsoft Leader club Session One – Dev Windows Phone 8 08/03/2013
  • 3. Get €50,000 for your Windows Phone app idea! The winner will also get a free trip to Finland to participate in a 4-week developer camp. Compete for the Worldwide Imagine Cup AppCampus Award! Top finalists incorporating a Windows Phone app into their project are eligible to win. Through this mobile application accelerator program, Microsoft and Nokia provide grants to fund innovative, first-to-market ideas with a fresh approach on design elegance, superior quality and performance
  • 4.
  • 6. The Windows Phone Emulator •The Windows Phone emulator runs as a Hyper-V virtual machine on your Windows PC • •It contains the same software as a “real” phone, but built for the Windows PC platform
  • 7. Page Navigation Frame and Page •Frame •Top-level container control •PhoneApplicationFrame class •Contains the page control and system elements such as system tray and application bar •Page •Fills entire content region of the frame •PhoneApplicationPage-derived class •Contains a title •Optionally surfaces its own application bar
  • 8. Using a Grid to Aid Landscape Layout • <phone:PivotItem Header="recipe"> • <Grid> • <Grid.ColumnDefinitions> • <ColumnDefinition Width="*"/> • <ColumnDefinition Width="Auto"/> • </Grid.ColumnDefinitions> • <Grid.RowDefinitions> • <RowDefinition Height="Auto"/> • <RowDefinition Height="240"/> • <RowDefinition Height="*"/> • <RowDefinition Height="Auto"/> • </Grid.RowDefinitions> • ... • </Grid>
  • 9. Handling Screen Orientation Changes Selecting Orientations SupportedOrientations="Portrait« SupportedOrientations="PortraitOrLandscape« • •A XAML property for the phone application page lets you select the orientation options available • •Your application can bind to an event which is fired when the orientation changes
  • 10. Moving Elements • private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e) { if (this.Orientation == PageOrientation.LandscapeLeft || this.Orientation == PageOrientation.LandscapeRight) { DirectionsScrollViewer.SetValue(Grid.RowProperty, 1); DirectionsScrollViewer.SetValue(Grid.ColumnProperty, 1); } else { DirectionsScrollViewer.SetValue(Grid.RowProperty, 2); DirectionsScrollViewer.SetValue(Grid.ColumnProperty, 0); } }
  • 11. Page Navigation •XAML apps on Windows Phone use a page-based navigation model •Similar to web page model •Each page identified by a URI •Each page is essentially stateless private void HyperlinkButton_Click_1( object sender, RoutedEventArgs e) { NavigationService.Navigate( new Uri("/SecondPage.xaml", UriKind.Relative)); }
  • 12. Navigating Back •Application can provide controls to navigate back to preceding page •The hardware Back key will also navigate back to preceding page •No code required – built-in behaviour private void Button_Click_1( object sender, RoutedEventArgs e) { NavigationService.GoBack(); }
  • 13. Passing Data Between Pages • •Can pass string data between pages using query strings private void passParam_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate(new Uri("/SecondPage.xaml?msg=" + textBox1.Text, UriKind.Relative)); } • •On destination page protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); string querystringvalue = ""; if (NavigationContext.QueryString.TryGetValue("msg", out querystringvalue)) textBlock1.Text = querystringvalue; }
  • 14. Isolated Storage Classes • •The IsolatedStorage classes are all in the System.IO.IsolatedStorage namespace • •IsolatedStorageFile • •Represents an isolated storage area containing files and directories • •IsolatedFileStream • •Exposes a file stream access to a file stored within isolated storage • •IsolatedStorageSettings • •Dictionary<(Of <(TKey, TValue>)>) that stores key-value pairs in isolated storage
  • 15. Local Folder • •All read-write I/O operations restricted to local folder • •Create a files and folder structure hierarchy • •Use Isolated Settings storage to store application settings
  • 16. Saving Data private void saveGameToIsolatedStorage(string message) { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream rawStream = isf.CreateFile("MyFile.store")) { StreamWriter writer = new StreamWriter(rawStream); writer.WriteLine(message); // save the message writer.Close(); } } }
  • 17. Loading Data private string loadString() { string result = null; using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { if (isf.FileExists("Myfile.store") { using (IsolatedStorageFileStream rawStream = isf.OpenFile(filename, System.IO.FileMode.Open)) { StreamReader reader = new StreamReader(rawStream); result = reader.ReadLine(); reader.Close(); }}} return result; }
  • 18. Capture Camera Code XAML <Button x:Name="CaptureCameraButton" Content="Capture Camera" Width="300" Height="100" Margin="0,81,156,426" Click="CaptureCameraButton_Click" /> <Image Height="150" HorizontalAlignment="Left" Margin="12,348,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="200" /> Code c# private void CaptureCameraButton_Click(object sender, RoutedEventArgs e) { CameraCaptureTask cct = new CameraCaptureTask(); cct.Completed += new EventHandler<PhotoResult>(cct_Completed); cct.Show(); } void cct_Completed(object sender, PhotoResult e) { BitmapImage bmp = new BitmapImage(); bmp.SetSource(e.ChosenPhoto); image1.Source = bmp; }
  • 19. Get PHOTO Code XAML • <Button x:Name="GetPhotoButton" Content="Get Photo" Width="300" Height="100" Margin="0,242,156,265" Click="GetPhotoButton_Click" /> • <Image Height="150" HorizontalAlignment="Left" Margin="12,348,0,0" Name="image2" Stretch="Fill" VerticalAlignment="Top" Width="200" /> Code c# private void GetPhotoButton_Click(object sender, RoutedEventArgs e) { PhotoChooserTask pct = new PhotoChooserTask(); pct.Completed += new EventHandler<PhotoResult>(pct_Completed); pct.Show(); } void pct_Completed(object sender, PhotoResult e) { BitmapImage bmp = new BitmapImage(); bmp.SetSource(e.ChosenPhoto); image2.Source = bmp; }
  • 20. Anwar YAHYAOUI • President du club Microsoft Leader • Email: anwar.yahyawi@live.fr • Mobile: (+216) 24 23 41 73