O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Windows Application Development Cookbook

Book Description

Discover over 125 solution-based recipes to help you build applications for smartphones, tablets, and desktops

About This Book

  • Learn to build applications for Windows 10, the latest Windows version
  • Develop your applications to be compatible with smartphones, tablets, and desktops
  • This guide is packed with recipes covering major solutions to day-to-day problems faced by Windows programmers

Who This Book Is For

The book is dedicated to programmers with various experience of developing applications for Windows-based smartphones, tablets, and desktops—even beginners can find suitable content.

What You Will Learn

  • Start developing universal applications for Windows 10
  • Design user interface in the XAML language
  • Use the MVVM design pattern with data binding
  • Store data in files and in a database
  • Use multimedia content and animations
  • Capture data from built-in sensors
  • Handle various Internet-based scenarios
  • Test the application and submit it to the Windows Store

In Detail

Need to ensure you can always create the best Windows apps regardless of platform? What you need are solutions to the biggest issues you can face, so you can always ensure you’re making the right choices and creating the best apps you can.

The book starts with recipes that will help you set up the integrated development environment before you go ahead and design the user interface. You will learn how to use the MVVM design pattern together with data binding, as well as how to work with data in different file formats.

Moving on, you will explore techniques to add animations and graphics to your application, and enable your solution to work with multimedia content.

You will also see how to use sensors, such as an accelerometer and a compass, as well as obtain the current GPS location. You will make your application ready to work with Internet-based scenarios, such as composing e-mails or downloading files, before finally testing the project and submitting it to the Windows Store.

By the end of the book, you will have a market-ready application compatible across different Windows devices, including smartphones, tablets, and desktops.

Style and approach

This quick-start book takes a cookbook format with recipes covering more than 125 solutions to help you create and build applications for Windows 10. The examples presented in the book use the free integrated development environment. A supporting set of codes that present solutions to problems described in particular chapters is available as well.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Windows Application Development Cookbook
    1. Windows Application Development Cookbook
    2. Credits
    3. About the Author
    4. Acknowledgements
    5. About the Reviewer
    6. www.PacktPub.com
      1. Why subscribe?
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Sections
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      5. Conventions
      6. Reader feedback
      7. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Getting Started
      1. Introduction
      2. Setting up the IDE
        1. Getting ready
        2. How to do it...
        3. There's more...
        4. See also
      3. Arranging windows
        1. Getting ready
        2. How to do it...
        3. There's more...
        4. See also
      4. Creating a new project
        1. Getting ready
        2. How to do it...
        3. There's more...
        4. See also
      5. Running the application
        1. Getting ready
        2. How to do it...
        3. See also
      6. Adding a new page
        1. Getting ready
        2. How to do it...
        3. There's more...
        4. See also
      7. Placing a control
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      8. Handling events
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Navigating between pages
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Passing data between pages
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      11. Handling the back button
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      12. Changing a default page
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      13. Modifying the back stack
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      14. Utilizing additional features of the emulator
        1. Getting ready
        2. How to do it...
        3. See also
      15. Breakpoints-based debugging
        1. Getting ready
        2. How to do it...
        3. See also
      16. Step-by-step debugging
        1. Getting ready
        2. How to do it...
        3. There's more...
        4. See also
      17. Executing code while debugging
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      18. Logging information while debugging
        1. Getting ready
        2. How to do it...
        3. See also
      19. Monitoring the CPU and memory usage
        1. Getting ready
        2. How to do it...
        3. How it works...
    9. 2. Designing a User Interface
      1. Introduction
      2. Adding a button
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      3. Adding a text block
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Adding a textbox
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Adding a password box
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Adding a checkbox
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Adding a combobox
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Adding a listbox
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Adding an image
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Adding controls programmatically
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      11. Arranging controls vertically
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      12. Arranging controls horizontally
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      13. Arranging controls in a scrollable view
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      14. Defining a page-limited style
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      15. Defining a global style
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      16. Applying styles programmatically
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      17. Arranging controls in a grid
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      18. Arranging controls in absolute positions
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      19. Choosing date and time
        1. Getting ready
        2. How to do it...
        3. How it works...
      20. Adding icons to app bars
        1. Getting ready
        2. How to do it...
        3. How it works...
      21. Creating and using a user control
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      22. Presenting a message dialog
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      23. Adjusting design based on the device type
        1. Getting ready
        2. How to do it...
        3. How it works...
      24. Localizing content in XAML
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      25. Localizing content programmatically
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      26. Forcing the current language
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    10. 3. MVVM and Data Binding
      1. Introduction
      2. Creating the view model for a page
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      3. Introducing bindings and commands
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Binding a value to a textbox
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Binding with a value converter
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Using value converters with parameters
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Showing a progress bar during calculations
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Binding a collection to a list view
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Binding a collection to a grid view
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Binding a collection to a combobox
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      11. Binding a collection to a hub
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    11. 4. Data Storage
      1. Introduction
      2. Creating a directory
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      3. Reading a structure of directories
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Creating a file
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Iterating through files
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more ...
        5. See also
      6. Renaming a directory
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Renaming a file
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Removing a directory
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Removing a file
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Writing a text file
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      11. Reading a text file
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      12. Writing an XML file
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      13. Reading an XML file
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      14. Writing a JSON file
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      15. Reading a JSON file
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      16. Writing a binary file
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      17. Reading a binary file
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      18. Creating a SQLite database and tables
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      19. Storing data in a SQLite database
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      20. Selecting data from a SQLite database
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      21. Updating data in a SQLite database
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      22. Removing data from a SQLite database
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    12. 5. Animations and Graphics
      1. Introduction
      2. Animating the showing of controls
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      3. Using animation to hide controls
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Adding animation to show the collection of items
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Animating the repositioning of items' collection
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Animating the color of an element
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Animating the size of an element
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Animating the position of an element
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Animating the rotation of an element
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Animating the font size of an element
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      11. Drawing shapes programmatically
        1. Getting ready
        2. How to do it...
        3. How it works...
      12. Handling the tap touch event
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      13. Handling the pinch touch event
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      14. Handling the rotate touch event
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      15. Handling the pinch and rotate touch events
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      16. Rendering 3D graphics
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    13. 6. Multimedia
      1. Introduction
      2. Playing a movie clip
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      3. Playing an audio file
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Presenting a collection of photos
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Preparing a photo album with captions
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Modifying an image
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Converting an image into grayscale
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Recoloring an image
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      9. Choosing a file to open
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Choosing a file to save
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      11. Taking an image from a camera
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      12. Recording a movie from a camera
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      13. Scanning a QR code
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      14. Synthesizing speech
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      15. Recognizing speech
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    14. 7. Built-in Sensors
      1. Introduction
      2. Detecting motion using an accelerometer
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      3. Reading data from a compass
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Obtaining the orientation of a device
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Reading data from a light sensor
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Launching vibrations
        1. Getting ready
        2. How to do it...
        3. How it works...
      7. Reading NFC tags
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Obtaining the current GPS location
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Disabling switching off the screen
        1. Getting ready
        2. How to do it...
        3. How it works...
    15. 8. Internet-based Scenarios
      1. Introduction
      2. Opening a website in a default browser
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      3. Presenting a website within a page
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Composing an e-mail message
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Starting a phone call
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Launching a Skype call
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Opening a map in an external application
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Showing a map within a page
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Drawing icons, polylines, and polygons on a map
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Adding a custom marker to a map
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      11. Getting the coordinates of a clicked point on a map
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      12. Launching GPS-based navigation
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      13. Calling API methods
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      14. Downloading a file from the Internet
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    16. 9. Testing and Submission
      1. Introduction
      2. Creating a unit test
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      3. Running a set of tests
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Adding a project to the Windows Dev Center
        1. How to do it...
        2. See also
      5. Associating an application with the store
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Adjusting the manifest file
        1. Getting ready
        2. How to do it...
        3. See also
      7. Obtaining a map token
        1. Getting ready
        2. How to do it...
        3. See also
      8. Receiving push notifications
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      9. Preparing files for submission
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      10. Submitting the application
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      11. Updating the application
        1. Getting ready
        2. How to do it...
        3. See also
      12. Generating promotional codes
        1. Getting ready
        2. How to do it...
        3. See also
      13. Browsing reviews and ratings
        1. Getting ready
        2. How to do it...
        3. See also
      14. Analyzing acquisitions
        1. Getting ready
        2. How to do it...
        3. See also
    17. A. Useful Resources
      1. Getting started
      2. Designing a User Interface
      3. MVVM and data binding
      4. Data storage
      5. Animations and graphics
      6. Multimedia
      7. Built-in sensors
      8. Internet-based scenarios
      9. Testing and submission